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
# 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::SANDBOX,
    method: "POST",
    path: "v2/bookings/custom-attributes/bulk-delete",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::BulkDeleteBookingCustomAttributesResponse.load(_response.body)
  end

  raise _response.body
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*.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/square/bookings/custom_attributes/client.rb', line 45

def batch_upsert(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "POST",
    path: "v2/bookings/custom-attributes/bulk-upsert",
    body: params
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::BulkUpsertBookingCustomAttributesResponse.load(_response.body)
  end

  raise _response.body
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*.



145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/square/bookings/custom_attributes/client.rb', line 145

def delete(request_options: {}, **params)
  _request = Square::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "DELETE",
    path: "v2/bookings/#{params[:booking_id]}/custom-attributes/#{params[:key]}"
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::DeleteBookingCustomAttributeResponse.load(_response.body)
  end

  raise _response.body
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.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/square/bookings/custom_attributes/client.rb', line 91

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: request_options[:base_url] || Square::Environment::SANDBOX,
    method: "GET",
    path: "v2/bookings/#{params[:booking_id]}/custom-attributes/#{params[:key]}",
    query: _query
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::RetrieveBookingCustomAttributeResponse.load(_response.body)
  end

  raise _response.body
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.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/square/bookings/custom_attributes/client.rb', line 66

def list(request_options: {}, **params)
  _query_param_names = %w[limit cursor with_definitions]
  _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::SANDBOX,
    method: "GET",
    path: "v2/bookings/#{params[:booking_id]}/custom-attributes",
    query: _query
  )
  _response = @client.send(_request)
  if _response.code >= "200" && _response.code < "300"
    return Square::Types::ListBookingCustomAttributesResponse.load(_response.body)
  end

  raise _response.body
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*.



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/square/bookings/custom_attributes/client.rb', line 119

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::SANDBOX,
    method: "PUT",
    path: "v2/bookings/#{params[:booking_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::UpsertBookingCustomAttributeResponse.load(_response.body)
  end

  raise _response.body
end