Class: Square::Merchants::CustomAttributes::Client
- Inherits:
-
Object
- Object
- Square::Merchants::CustomAttributes::Client
- Defined in:
- lib/square/merchants/custom_attributes/client.rb
Instance Method Summary collapse
-
#batch_delete(request_options: {}, **params) ⇒ Square::Types::BulkDeleteMerchantCustomAttributesResponse
Deletes [custom attributes](entity:CustomAttribute) for a merchant as a bulk operation.
-
#batch_upsert(request_options: {}, **params) ⇒ Square::Types::BulkUpsertMerchantCustomAttributesResponse
Creates or updates [custom attributes](entity:CustomAttribute) for a merchant as a bulk operation.
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteMerchantCustomAttributeResponse
Deletes a [custom attribute](entity:CustomAttribute) associated with a merchant.
-
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveMerchantCustomAttributeResponse
Retrieves a [custom attribute](entity:CustomAttribute) associated with a merchant.
- #initialize(client:) ⇒ Square::Merchants::CustomAttributes::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListMerchantCustomAttributesResponse
Lists the [custom attributes](entity:CustomAttribute) associated with a merchant.
-
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertMerchantCustomAttributeResponse
Creates or updates a [custom attribute](entity:CustomAttribute) for a merchant.
Constructor Details
#initialize(client:) ⇒ Square::Merchants::CustomAttributes::Client
8 9 10 |
# File 'lib/square/merchants/custom_attributes/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#batch_delete(request_options: {}, **params) ⇒ Square::Types::BulkDeleteMerchantCustomAttributesResponse
Deletes [custom attributes](entity:CustomAttribute) for a merchant as a bulk operation. To delete a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/square/merchants/custom_attributes/client.rb', line 17 def batch_delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/merchants/custom-attributes/bulk-delete", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkDeleteMerchantCustomAttributesResponse.load(_response.body) end raise _response.body end |
#batch_upsert(request_options: {}, **params) ⇒ Square::Types::BulkUpsertMerchantCustomAttributesResponse
Creates or updates [custom attributes](entity:CustomAttribute) for a merchant as a bulk operation. Use this endpoint to set the value of one or more custom attributes for a merchant. A custom attribute is based on a custom attribute definition in a Square seller account, which is created using the [CreateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-CreateMerchantCustomAttributeDefinition) endpoint. This ‘BulkUpsertMerchantCustomAttributes` endpoint accepts a map of 1 to 25 individual upsert requests and returns a map of individual upsert responses. Each upsert request has a unique ID and provides a merchant ID and custom attribute. Each upsert response is returned with the ID of the corresponding request. To create or update a custom attribute owned by another application, the `visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/square/merchants/custom_attributes/client.rb', line 44 def batch_upsert(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/merchants/custom-attributes/bulk-upsert", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkUpsertMerchantCustomAttributesResponse.load(_response.body) end raise _response.body end |
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteMerchantCustomAttributeResponse
Deletes a [custom attribute](entity:CustomAttribute) associated with a merchant. To delete a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`.
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/square/merchants/custom_attributes/client.rb', line 142 def delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "DELETE", path: "v2/merchants/#{params[:merchant_id]}/custom-attributes/#{params[:key]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::DeleteMerchantCustomAttributeResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveMerchantCustomAttributeResponse
Retrieves a [custom attribute](entity:CustomAttribute) associated with a merchant. You can use the ‘with_definition` query parameter to also retrieve the custom attribute definition in the same call. To retrieve a custom attribute owned by another application, the `visibility` setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/square/merchants/custom_attributes/client.rb', line 93 def get(request_options: {}, **params) _query_param_names = %w[with_definition 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/#{params[:merchant_id]}/custom-attributes/#{params[:key]}", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::RetrieveMerchantCustomAttributeResponse.load(_response.body) end raise _response.body end |
#list(request_options: {}, **params) ⇒ Square::Types::ListMerchantCustomAttributesResponse
Lists the [custom attributes](entity:CustomAttribute) associated with a merchant. You can use the ‘with_definitions` query parameter to also retrieve custom attribute definitions in the same call. When all response pages are retrieved, the results include all custom attributes that are visible to the requesting application, including those that are owned by other applications and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/square/merchants/custom_attributes/client.rb', line 67 def list(request_options: {}, **params) _query_param_names = %w[visibility_filter limit cursor with_definitions] _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/#{params[:merchant_id]}/custom-attributes", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListMerchantCustomAttributesResponse.load(_response.body) end raise _response.body end |
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertMerchantCustomAttributeResponse
Creates or updates a [custom attribute](entity:CustomAttribute) for a merchant. Use this endpoint to set the value of a custom attribute for a specified merchant. A custom attribute is based on a custom attribute definition in a Square seller account, which is created using the [CreateMerchantCustomAttributeDefinition](api-endpoint:MerchantCustomAttributes-CreateMerchantCustomAttributeDefinition) endpoint. To create or update a custom attribute owned by another application, the ‘visibility` setting must be `VISIBILITY_READ_WRITE_VALUES`.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/square/merchants/custom_attributes/client.rb', line 120 def upsert(request_options: {}, **params) _path_param_names = %w[merchant_id key] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/merchants/#{params[:merchant_id]}/custom-attributes/#{params[:key]}", body: params.except(*_path_param_names) ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::UpsertMerchantCustomAttributeResponse.load(_response.body) end raise _response.body end |