Class: Square::CardsApi
Overview
CardsApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_card(body:) ⇒ CreateCardResponse Hash
Adds a card on file to an existing merchant.
-
#disable_card(card_id:) ⇒ DisableCardResponse Hash
Disables the card, preventing any further updates or charges.
-
#list_cards(cursor: nil, customer_id: nil, include_disabled: false, reference_id: nil, sort_order: nil) ⇒ ListCardsResponse Hash
Retrieves a list of cards owned by the account making the request.
-
#retrieve_card(card_id:) ⇒ RetrieveCardResponse Hash
Retrieves details for a specific Card.
Methods inherited from BaseApi
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from Square::BaseApi
Instance Method Details
#create_card(body:) ⇒ CreateCardResponse Hash
Adds a card on file to an existing merchant. the fields to POST for the request. See the corresponding object definition for field details.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/square/api/cards_api.rb', line 51 def create_card(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/cards', 'default') .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#disable_card(card_id:) ⇒ DisableCardResponse Hash
Disables the card, preventing any further updates or charges. Disabling an already disabled card is allowed but has no effect. Card.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/square/api/cards_api.rb', line 93 def disable_card(card_id:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/cards/{card_id}/disable', 'default') .template_param(new_parameter(card_id, key: 'card_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#list_cards(cursor: nil, customer_id: nil, include_disabled: false, reference_id: nil, sort_order: nil) ⇒ ListCardsResponse Hash
Retrieves a list of cards owned by the account making the request. A max of 25 cards will be returned. a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See [Pagination](developer.squareup.com/docs/build-basics/common-api-p atterns/pagination) for more information. associated with the customer supplied. By default, all cards owned by the merchant are returned. Includes disabled cards. By default, all enabled cards owned by the merchant are returned. associated with the reference_id supplied. by when the card was created with the specified order. This field defaults to ASC.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/square/api/cards_api.rb', line 23 def list_cards(cursor: nil, customer_id: nil, include_disabled: false, reference_id: nil, sort_order: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/cards', 'default') .query_param(new_parameter(cursor, key: 'cursor')) .query_param(new_parameter(customer_id, key: 'customer_id')) .query_param(new_parameter(include_disabled, key: 'include_disabled')) .query_param(new_parameter(reference_id, key: 'reference_id')) .query_param(new_parameter(sort_order, key: 'sort_order')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#retrieve_card(card_id:) ⇒ RetrieveCardResponse Hash
Retrieves details for a specific Card. Card.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/square/api/cards_api.rb', line 72 def retrieve_card(card_id:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/cards/{card_id}', 'default') .template_param(new_parameter(card_id, key: 'card_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |