Module: TpagaService::CreditCardApi

Extended by:
CreditCardApi
Included in:
CreditCardApi
Defined in:
lib/tpaga_service/api/credit_card_api.rb

Instance Method Summary collapse

Instance Method Details

#add_credit_card(data, customer_id = nil) ⇒ Object



5
6
7
8
# File 'lib/tpaga_service/api/credit_card_api.rb', line 5

def add_credit_card(data, customer_id=nil)
  customer_id = customer_id || data[:customer_id]
  return create_credit_card(get_created_credit_card(data), customer_id)
end

#delete_credit_card_by_id(customer_id, credit_card_id) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tpaga_service/api/credit_card_api.rb', line 10

def delete_credit_card_by_id(customer_id, credit_card_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}/credit_card/#{credit_card_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 true
end