Class: Square::Vendors::Client
- Inherits:
-
Object
- Object
- Square::Vendors::Client
- Defined in:
- lib/square/vendors/client.rb
Instance Method Summary collapse
-
#batch_create(request_options: {}, **params) ⇒ Square::Types::BatchCreateVendorsResponse
Creates one or more Vendor objects to represent suppliers to a seller.
-
#batch_get(request_options: {}, **params) ⇒ Square::Types::BatchGetVendorsResponse
Retrieves one or more vendors of specified Vendor IDs.
-
#batch_update(request_options: {}, **params) ⇒ Square::Types::BatchUpdateVendorsResponse
Updates one or more of existing Vendor objects as suppliers to a seller.
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateVendorResponse
Creates a single Vendor object to represent a supplier to a seller.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetVendorResponse
Retrieves the vendor of a specified Vendor ID.
- #initialize(client:) ⇒ void constructor
-
#search(request_options: {}, **params) ⇒ Square::Types::SearchVendorsResponse
Searches for vendors using a filter against supported Vendor properties and a supported sorter.
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdateVendorResponse
Updates an existing Vendor object as a supplier to a seller.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/square/vendors/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#batch_create(request_options: {}, **params) ⇒ Square::Types::BatchCreateVendorsResponse
Creates one or more Vendor objects to represent suppliers to a seller.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/square/vendors/client.rb', line 24 def batch_create(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/vendors/bulk-create", body: Square::Vendors::Types::BatchCreateVendorsRequest.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::BatchCreateVendorsResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#batch_get(request_options: {}, **params) ⇒ Square::Types::BatchGetVendorsResponse
Retrieves one or more vendors of specified Vendor IDs.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/square/vendors/client.rb', line 58 def batch_get(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/vendors/bulk-retrieve", body: Square::Vendors::Types::BatchGetVendorsRequest.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::BatchGetVendorsResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#batch_update(request_options: {}, **params) ⇒ Square::Types::BatchUpdateVendorsResponse
Updates one or more of existing Vendor objects as suppliers to a seller.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/square/vendors/client.rb', line 92 def batch_update(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "v2/vendors/bulk-update", body: Square::Vendors::Types::BatchUpdateVendorsRequest.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::BatchUpdateVendorsResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create(request_options: {}, **params) ⇒ Square::Types::CreateVendorResponse
Creates a single Vendor object to represent a supplier to a seller.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/square/vendors/client.rb', line 126 def create(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/vendors/create", body: Square::Vendors::Types::CreateVendorRequest.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::CreateVendorResponse.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::GetVendorResponse
Retrieves the vendor of a specified Vendor ID.
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/square/vendors/client.rb', line 195 def get(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/vendors/#{params[:vendor_id]}", 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::GetVendorResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#search(request_options: {}, **params) ⇒ Square::Types::SearchVendorsResponse
Searches for vendors using a filter against supported Vendor properties and a supported sorter.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/square/vendors/client.rb', line 160 def search(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/vendors/search", body: Square::Vendors::Types::SearchVendorsRequest.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::SearchVendorsResponse.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::UpdateVendorResponse
Updates an existing Vendor object as a supplier to a seller.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/square/vendors/client.rb', line 229 def update(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) path_param_names = %i[vendor_id] body_params = params.except(*path_param_names) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "v2/vendors/#{params[:vendor_id]}", body: Square::Types::UpdateVendorRequest.new(body_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::UpdateVendorResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |