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::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::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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/payabli/ghost_card/client.rb', line 52 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 = %w[entry] body = request_data.except(*non_body_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "MoneyOutCard/GhostCard/#{URI.encode_uri_component(params[:entry].to_s)}", headers: headers, 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::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.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/payabli/ghost_card/client.rb', line 100 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 = %w[entry] body = request_data.except(*non_body_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "MoneyOutCard/card/#{URI.encode_uri_component(params[:entry].to_s)}", headers: headers, 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 |