Class: Square::Bookings::CustomAttributes::Client
- Inherits:
-
Object
- Object
- Square::Bookings::CustomAttributes::Client
- Defined in:
- lib/square/bookings/custom_attributes/client.rb
Instance Method Summary collapse
-
#batch_delete(request_options: {}, **params) ⇒ Square::Types::BulkDeleteBookingCustomAttributesResponse
Bulk deletes bookings custom attributes.
-
#batch_upsert(request_options: {}, **params) ⇒ Square::Types::BulkUpsertBookingCustomAttributesResponse
Bulk upserts bookings custom attributes.
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteBookingCustomAttributeResponse
Deletes a bookings custom attribute.
-
#get(request_options: {}, **params) ⇒ Square::Types::RetrieveBookingCustomAttributeResponse
Retrieves a bookings custom attribute.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListBookingCustomAttributesResponse
Lists a booking’s custom attributes.
-
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertBookingCustomAttributeResponse
Upserts a bookings custom attribute.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/square/bookings/custom_attributes/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#batch_delete(request_options: {}, **params) ⇒ Square::Types::BulkDeleteBookingCustomAttributesResponse
Bulk deletes bookings custom attributes.
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*.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/square/bookings/custom_attributes/client.rb', line 33 def batch_delete(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/bookings/custom-attributes/bulk-delete", body: Square::Bookings::CustomAttributes::Types::BulkDeleteBookingCustomAttributesRequest.new(params).to_h, request_options: ) 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::BulkDeleteBookingCustomAttributesResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#batch_upsert(request_options: {}, **params) ⇒ Square::Types::BulkUpsertBookingCustomAttributesResponse
Bulk upserts bookings custom attributes.
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*.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/square/bookings/custom_attributes/client.rb', line 75 def batch_upsert(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v2/bookings/custom-attributes/bulk-upsert", body: Square::Bookings::CustomAttributes::Types::BulkUpsertBookingCustomAttributesRequest.new(params).to_h, request_options: ) 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::BulkUpsertBookingCustomAttributesResponse.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::DeleteBookingCustomAttributeResponse
Deletes a bookings custom attribute.
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*.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/square/bookings/custom_attributes/client.rb', line 271 def delete(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "v2/bookings/#{params[:booking_id]}/custom-attributes/#{params[:key]}", request_options: ) 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::DeleteBookingCustomAttributeResponse.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::RetrieveBookingCustomAttributeResponse
Retrieves a bookings custom attribute.
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.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/square/bookings/custom_attributes/client.rb', line 173 def get(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[with_definition version] query_params = {} query_params["with_definition"] = params[:with_definition] if params.key?(:with_definition) query_params["version"] = params[:version] if params.key?(:version) params = params.except(*query_param_names) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/bookings/#{params[:booking_id]}/custom-attributes/#{params[:key]}", query: query_params, request_options: ) 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::RetrieveBookingCustomAttributeResponse.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::ListBookingCustomAttributesResponse
Lists a booking’s custom attributes.
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.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/square/bookings/custom_attributes/client.rb', line 117 def list(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[limit cursor with_definitions] query_params = {} query_params["limit"] = params[:limit] if params.key?(:limit) query_params["cursor"] = params[:cursor] if params.key?(:cursor) query_params["with_definitions"] = params[:with_definitions] if params.key?(:with_definitions) params = params.except(*query_param_names) Square::Internal::CursorItemIterator.new( cursor_field: :cursor, item_field: :custom_attributes, initial_cursor: query_params[:cursor] ) do |next_cursor| query_params[:cursor] = next_cursor request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/bookings/#{params[:booking_id]}/custom-attributes", query: query_params, request_options: ) 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::ListBookingCustomAttributesResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertBookingCustomAttributeResponse
Upserts a bookings custom attribute.
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*.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/square/bookings/custom_attributes/client.rb', line 223 def upsert(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request_data = Square::Bookings::CustomAttributes::Types::UpsertBookingCustomAttributeRequest.new(params).to_h non_body_param_names = %w[booking_id key] body = request_data.except(*non_body_param_names) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "v2/bookings/#{params[:booking_id]}/custom-attributes/#{params[:key]}", body: body, request_options: ) 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::UpsertBookingCustomAttributeResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |