Class: Square::MerchantsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/merchants_api.rb

Overview

MerchantsApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

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

#list_merchants(cursor: nil) ⇒ ListMerchantsResponse Hash

Provides details about the merchant associated with a given access token. The access token used to connect your application to a Square seller is associated with a single merchant. That means that ‘ListMerchants` returns a list with a single `Merchant` object. You can specify your personal access token to get your own merchant information or specify an OAuth token to get the information for the merchant that granted your application access. If you know the merchant ID, you can also use the [RetrieveMerchant]($e/Merchants/RetrieveMerchant) endpoint to retrieve the merchant information. previous response.

Parameters:

  • cursor (Integer) (defaults to: nil)

    Optional parameter: The cursor generated by the

Returns:

  • (ListMerchantsResponse Hash)

    response from the API call



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/square/api/merchants_api.rb', line 18

def list_merchants(cursor: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/merchants',
                                 'default')
               .query_param(new_parameter(cursor, key: 'cursor'))
               .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_merchant(merchant_id:) ⇒ RetrieveMerchantResponse Hash

Retrieves the ‘Merchant` object for the given `merchant_id`. retrieve. If the string “me” is supplied as the ID, then retrieve the merchant that is currently accessible to this call.

Parameters:

  • merchant_id (String)

    Required parameter: The ID of the merchant to

Returns:

  • (RetrieveMerchantResponse Hash)

    response from the API call



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/square/api/merchants_api.rb', line 38

def retrieve_merchant(merchant_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/merchants/{merchant_id}',
                                 'default')
               .template_param(new_parameter(merchant_id, key: 'merchant_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