module TpagaService::CustomerApi

Public Instance Methods

create_customer(data) click to toggle source
Parameters:

*data Hash - { firstName: '', lastName: '', email: '', phone: '' }

Return:

Hash - {"id"=>"cus-ljcvjfcc4mwzh4j2qmv40gqqu2x2", "firstName"=>"Sta. Elisa Melgar Arteaga", "lastName"=>"Sta. Elisa Melgar Arteaga", "gender"=>nil, "email"=>"luciokling@wintheiser.org", "phone"=>"9521559", "legalIdNumber"=>nil, "merchantCustomerId"=>nil}

# File lib/tpaga_service/api/customer_api.rb, line 9
def create_customer(data)
  host = Swagger.configuration.host
  api_key = Swagger.configuration.private_api_key

  conn = Faraday.new
  resp = conn.post do |req|
    req.url "https://#{host}/api/customer"
    req.headers['Content-Type'] = 'application/json'
    req.headers['Authorization'] = 'Basic ' + ["#{api_key}:"].pack('m').delete("\r\n")
    req.body = data.to_json
  end
  body = JSON.parse(resp.body)
  Swagger::Response.new(resp.status, body)
  return body
end
delete_customer_by_id(customer_id) click to toggle source
Parameters:

*customer_id : String

# File lib/tpaga_service/api/customer_api.rb, line 65
def delete_customer_by_id(customer_id)
  host = Swagger.configuration.host
  api_key = Swagger.configuration.private_api_key

  conn = Faraday.new
  resp = conn.delete do |req|
    req.url "https://#{host}/api/customer/#{customer_id}"
    req.headers['Content-Type'] = 'application/json'
    req.headers['Authorization'] = 'Basic ' + ["#{api_key}:"].pack('m').delete("\r\n")
  end
  body = JSON.parse(resp.body)
  Swagger::Response.new(resp.status, body)
  return body
end
get_customer_by_id(customer_id) click to toggle source
Parameters:

*customer_id : String

Return:

Hash - {

"id": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"gender": "M",
"phone": "string",
"legalIdNumber": "string",
"merchantCustomerId": "string",
"address": {
  "addressLine1": "string",
  "addressLine2": "string",
  "postalCode": "string",
  "city": {
    "name": "Bogotá",
    "state": "DC",
    "country": "CO"
  }
}

}

# File lib/tpaga_service/api/customer_api.rb, line 48
def get_customer_by_id(customer_id)
  host = Swagger.configuration.host
  api_key = Swagger.configuration.private_api_key

  conn = Faraday.new
  resp = conn.get do |req|
    req.url "https://#{host}/api/customer/#{customer_id}"
    req.headers['Content-Type'] = 'application/json'
    req.headers['Authorization'] = 'Basic ' + ["#{api_key}:"].pack('m').delete("\r\n")
  end
  body = JSON.parse(resp.body)
  Swagger::Response.new(resp.status, body)
  return body
end