Class: Square::Bookings::CustomAttributes::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Square::Bookings::CustomAttributes::Client



8
9
10
# File 'lib/square/bookings/custom_attributes/client.rb', line 8

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*.



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

def batch_delete(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::PRODUCTION,
    method: "POST",
    path: "v2/bookings/custom-attributes/bulk-delete",
    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::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*.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/square/bookings/custom_attributes/client.rb', line 51

def batch_upsert(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::PRODUCTION,
    method: "POST",
    path: "v2/bookings/custom-attributes/bulk-upsert",
    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::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*.



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/square/bookings/custom_attributes/client.rb', line 181

def delete(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::PRODUCTION,
    method: "DELETE",
    path: "v2/bookings/#{params[:booking_id]}/custom-attributes/#{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::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.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/square/bookings/custom_attributes/client.rb', line 112

def get(request_options: {}, **params)
  _query_param_names = [
    %w[with_definition version],
    %i[with_definition version]
  ].flatten
  _query = params.slice(*_query_param_names)
  params = params.except(*_query_param_names)

  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::PRODUCTION,
    method: "GET",
    path: "v2/bookings/#{params[:booking_id]}/custom-attributes/#{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::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.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/square/bookings/custom_attributes/client.rb', line 78

def list(request_options: {}, **params)
  _query_param_names = [
    %w[limit cursor with_definitions],
    %i[limit cursor with_definitions]
  ].flatten
  _query = params.slice(*_query_param_names)
  params = params.except(*_query_param_names)

  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::PRODUCTION,
    method: "GET",
    path: "v2/bookings/#{params[:booking_id]}/custom-attributes",
    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::ListBookingCustomAttributesResponse.load(_response.body)
  else
    error_class = Square::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(_response.body, code: code)
  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*.



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/square/bookings/custom_attributes/client.rb', line 149

def upsert(request_options: {}, **params)
  _path_param_names = %w[booking_id key]

  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::PRODUCTION,
    method: "PUT",
    path: "v2/bookings/#{params[:booking_id]}/custom-attributes/#{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::UpsertBookingCustomAttributeResponse.load(_response.body)
  else
    error_class = Square::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(_response.body, code: code)
  end
end