Class: Square::Merchants::CustomAttributeDefinitions::Client
- Inherits:
-
Object
- Object
- Square::Merchants::CustomAttributeDefinitions::Client
- Defined in:
- lib/square/merchants/custom_attribute_definitions/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateMerchantCustomAttributeDefinitionResponse
Creates a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) for a Square seller account.
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteMerchantCustomAttributeDefinitionResponse
Deletes a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) from a Square seller account.
-
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveMerchantCustomAttributeDefinitionResponse
Retrieves a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) from a Square seller account.
- #initialize(client:) ⇒ Square::Merchants::CustomAttributeDefinitions::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListMerchantCustomAttributeDefinitionsResponse
Lists the merchant-related [custom attribute definitions](entity:CustomAttributeDefinition) that belong to a Square seller account.
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdateMerchantCustomAttributeDefinitionResponse
Updates a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) for a Square seller account.
Constructor Details
#initialize(client:) ⇒ Square::Merchants::CustomAttributeDefinitions::Client
8 9 10 |
# File 'lib/square/merchants/custom_attribute_definitions/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Square::Types::CreateMerchantCustomAttributeDefinitionResponse
Creates a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) for a Square seller account. Use this endpoint to define a custom attribute that can be associated with a merchant connecting to your application. A custom attribute definition specifies the ‘key`, `visibility`, `schema`, and other properties for a custom attribute. After the definition is created, you can call [UpsertMerchantCustomAttribute](api-endpoint:MerchantCustomAttributes-UpsertMerchantCustomAttribute) or [BulkUpsertMerchantCustomAttributes](api-endpoint:MerchantCustomAttributes-BulkUpsertMerchantCustomAttributes) to set the custom attribute for a merchant.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/square/merchants/custom_attribute_definitions/client.rb', line 46 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/merchants/custom-attribute-definitions", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::CreateMerchantCustomAttributeDefinitionResponse.load(_response.body) end raise _response.body end |
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteMerchantCustomAttributeDefinitionResponse
Deletes a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) from a Square seller account. Deleting a custom attribute definition also deletes the corresponding custom attribute from the merchant. Only the definition owner can delete a custom attribute definition.
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/square/merchants/custom_attribute_definitions/client.rb', line 114 def delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "DELETE", path: "v2/merchants/custom-attribute-definitions/#{params[:key]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::DeleteMerchantCustomAttributeDefinitionResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveMerchantCustomAttributeDefinitionResponse
Retrieves a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) from a Square seller account. To retrieve a custom attribute definition created by another application, the ‘visibility` setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/square/merchants/custom_attribute_definitions/client.rb', line 66 def get(request_options: {}, **params) _query_param_names = ["version"] _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/merchants/custom-attribute-definitions/#{params[:key]}", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::RetrieveMerchantCustomAttributeDefinitionResponse.load(_response.body) end raise _response.body end |
#list(request_options: {}, **params) ⇒ Square::Types::ListMerchantCustomAttributeDefinitionsResponse
Lists the merchant-related [custom attribute definitions](entity:CustomAttributeDefinition) that belong to a Square seller account. When all response pages are retrieved, the results include all custom attribute definitions that are visible to the requesting application, including those that are created by other applications and set to ‘VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/square/merchants/custom_attribute_definitions/client.rb', line 18 def list(request_options: {}, **params) _query_param_names = %w[visibility_filter limit cursor] _query = params.slice(*_query_param_names) params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/merchants/custom-attribute-definitions", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListMerchantCustomAttributeDefinitionsResponse.load(_response.body) end raise _response.body end |
#update(request_options: {}, **params) ⇒ Square::Types::UpdateMerchantCustomAttributeDefinitionResponse
Updates a merchant-related [custom attribute definition](entity:CustomAttributeDefinition) for a Square seller account. Use this endpoint to update the following fields: ‘name`, `description`, `visibility`, or the `schema` for a `Selection` data type. Only the definition owner can update a custom attribute definition.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/square/merchants/custom_attribute_definitions/client.rb', line 91 def update(request_options: {}, **params) _path_param_names = ["key"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "PUT", path: "v2/merchants/custom-attribute-definitions/#{params[:key]}", body: params.except(*_path_param_names) ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::UpdateMerchantCustomAttributeDefinitionResponse.load(_response.body) end raise _response.body end |