Class: Square::Merchants::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/square/merchants/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Square::Merchants::Client



7
8
9
# File 'lib/square/merchants/client.rb', line 7

def initialize(client:)
  @client = client
end

Instance Method Details

#custom_attribute_definitionsSquare::CustomAttributeDefinitions::Client

Returns:

  • (Square::CustomAttributeDefinitions::Client)


60
61
62
# File 'lib/square/merchants/client.rb', line 60

def custom_attribute_definitions
  @custom_attribute_definitions ||= Square::Merchants::CustomAttributeDefinitions::Client.new(client: @client)
end

#custom_attributesSquare::CustomAttributes::Client

Returns:

  • (Square::CustomAttributes::Client)


65
66
67
# File 'lib/square/merchants/client.rb', line 65

def custom_attributes
  @custom_attributes ||= Square::Merchants::CustomAttributes::Client.new(client: @client)
end

#get(request_options: {}, **params) ⇒ Square::Types::GetMerchantResponse

Retrieves the ‘Merchant` object for the given `merchant_id`.



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/square/merchants/client.rb', line 45

def get(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/merchants/#{params[:merchant_id]}"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::GetMerchantResponse.load(_response.body)
  end

  raise _response.body
end

#list(request_options: {}, **params) ⇒ Square::Types::ListMerchantsResponse

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](api-endpoint:Merchants-RetrieveMerchant) endpoint to retrieve the merchant information.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/square/merchants/client.rb', line 23

def list(request_options: {}, **params)
  _query_param_names = ["cursor"]
  _query = params.slice(*_query_param_names)
  params.except(*_query_param_names)

  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/merchants",
    query: _query
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::ListMerchantsResponse.load(_response.body)
  end

  raise _response.body
end