Class: Square::Bookings::CustomAttributeDefinitions::Client
- Inherits:
-
Object
- Object
- Square::Bookings::CustomAttributeDefinitions::Client
- Defined in:
- lib/square/bookings/custom_attribute_definitions/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateBookingCustomAttributeDefinitionResponse
Creates a bookings custom attribute definition.
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteBookingCustomAttributeDefinitionResponse
Deletes a bookings custom attribute definition.
-
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveBookingCustomAttributeDefinitionResponse
Retrieves a bookings custom attribute definition.
- #initialize(client:) ⇒ Square::Bookings::CustomAttributeDefinitions::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListBookingCustomAttributeDefinitionsResponse
Get all bookings custom attribute definitions.
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdateBookingCustomAttributeDefinitionResponse
Updates a bookings custom attribute definition.
Constructor Details
#initialize(client:) ⇒ Square::Bookings::CustomAttributeDefinitions::Client
8 9 10 |
# File 'lib/square/bookings/custom_attribute_definitions/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Square::Types::CreateBookingCustomAttributeDefinitionResponse
Creates a bookings custom attribute definition.
To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_WRITE` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus* or *Appointments Premium*.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/square/bookings/custom_attribute_definitions/client.rb', line 55 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/bookings/custom-attribute-definitions", body: params ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::CreateBookingCustomAttributeDefinitionResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteBookingCustomAttributeDefinitionResponse
Deletes a bookings custom attribute definition.
To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_WRITE` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus* or *Appointments Premium*.
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/square/bookings/custom_attribute_definitions/client.rb', line 151 def delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "DELETE", path: "v2/bookings/custom-attribute-definitions/#{params[:key]}" ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::DeleteBookingCustomAttributeDefinitionResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveBookingCustomAttributeDefinitionResponse
Retrieves a bookings custom attribute definition.
To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_READ` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/square/bookings/custom_attribute_definitions/client.rb', line 82 def get(request_options: {}, **params) _query_param_names = [ ["version"], %i[version] ].flatten _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/bookings/custom-attribute-definitions/#{params[:key]}", query: _query ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::RetrieveBookingCustomAttributeDefinitionResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#list(request_options: {}, **params) ⇒ Square::Types::ListBookingCustomAttributeDefinitionsResponse
Get all bookings custom attribute definitions.
To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_READ` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
18 19 20 21 22 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/bookings/custom_attribute_definitions/client.rb', line 18 def list(request_options: {}, **params) _query_param_names = [ %w[limit cursor], %i[limit cursor] ].flatten _query = params.slice(*_query_param_names) params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/bookings/custom-attribute-definitions", query: _query ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::ListBookingCustomAttributeDefinitionsResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#update(request_options: {}, **params) ⇒ Square::Types::UpdateBookingCustomAttributeDefinitionResponse
Updates a bookings custom attribute definition.
To call this endpoint with buyer-level permissions, set ‘APPOINTMENTS_WRITE` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus* or *Appointments Premium*.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/square/bookings/custom_attribute_definitions/client.rb', line 119 def update(request_options: {}, **params) _path_param_names = ["key"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "PUT", path: "v2/bookings/custom-attribute-definitions/#{params[:key]}", body: params.except(*_path_param_names) ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::UpdateBookingCustomAttributeDefinitionResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |