Class: Payabli::GhostCard::Client
- Inherits:
-
Object
- Object
- Payabli::GhostCard::Client
- Defined in:
- lib/payabli/ghost_card/client.rb
Instance Method Summary collapse
-
#create_ghost_card(request_options: {}, **params) ⇒ Payabli::GhostCard::Types::CreateGhostCardResponse
Creates a ghost card, a multi-use virtual debit card issued to a vendor for recurring or discretionary spend.
- #initialize(client:) ⇒ void constructor
-
#update_card(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse
Updates the status of a virtual card (including ghost cards) under a paypoint.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/ghost_card/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create_ghost_card(request_options: {}, **params) ⇒ Payabli::GhostCard::Types::CreateGhostCardResponse
Creates a ghost card, a multi-use virtual debit card issued to a vendor for recurring or discretionary spend.
Unlike single-use virtual cards issued as part of a payout transaction, ghost cards aren’t tied to a specific payout. They’re issued directly to a vendor and can be reused up to a configurable number of times within the card’s spending limits.
Only one ghost card can exist per vendor per paypoint. To issue a new card to the same vendor, cancel the existing card first.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/payabli/ghost_card/client.rb', line 32 def create_ghost_card(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request_data = Payabli::GhostCard::Types::CreateGhostCardRequestBody.new(params).to_h non_body_param_names = ["entry"] body = request_data.except(*non_body_param_names) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "MoneyOutCard/GhostCard/#{URI.encode_uri_component(params[:entry].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::GhostCard::Types::CreateGhostCardResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_card(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse
Updates the status of a virtual card (including ghost cards) under a paypoint.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/payabli/ghost_card/client.rb', line 71 def update_card(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request_data = Payabli::GhostCard::Types::UpdateCardRequestBody.new(params).to_h non_body_param_names = ["entry"] body = request_data.except(*non_body_param_names) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "MoneyOutCard/card/#{URI.encode_uri_component(params[:entry].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |