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](entity:Vendor) objects to represent suppliers to a seller.
-
#batch_get(request_options: {}, **params) ⇒ Square::Types::BatchGetVendorsResponse
Retrieves one or more vendors of specified [Vendor](entity:Vendor) IDs.
-
#batch_update(request_options: {}, **params) ⇒ Square::Types::BatchUpdateVendorsResponse
Updates one or more of existing [Vendor](entity:Vendor) objects as suppliers to a seller.
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateVendorResponse
Creates a single [Vendor](entity:Vendor) object to represent a supplier to a seller.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetVendorResponse
Retrieves the vendor of a specified [Vendor](entity:Vendor) ID.
- #initialize(client:) ⇒ Square::Vendors::Client constructor
-
#search(request_options: {}, **params) ⇒ Square::Types::SearchVendorsResponse
Searches for vendors using a filter against supported [Vendor](entity:Vendor) properties and a supported sorter.
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdateVendorResponse
Updates an existing [Vendor](entity:Vendor) object as a supplier to a seller.
Constructor Details
#initialize(client:) ⇒ Square::Vendors::Client
7 8 9 |
# File 'lib/square/vendors/client.rb', line 7 def initialize(client:) @client = client end |
Instance Method Details
#batch_create(request_options: {}, **params) ⇒ Square::Types::BatchCreateVendorsResponse
Creates one or more [Vendor](entity:Vendor) objects to represent suppliers to a seller.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/square/vendors/client.rb', line 14 def batch_create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/vendors/bulk-create", 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::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](entity:Vendor) IDs.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/square/vendors/client.rb', line 38 def batch_get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/vendors/bulk-retrieve", 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::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](entity:Vendor) objects as suppliers to a seller.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/square/vendors/client.rb', line 62 def batch_update(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "PUT", path: "v2/vendors/bulk-update", 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::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](entity:Vendor) object to represent a supplier to a seller.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/square/vendors/client.rb', line 86 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/vendors/create", 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::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](entity:Vendor) ID.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/square/vendors/client.rb', line 134 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "GET", path: "v2/vendors/#{params[:vendor_id]}" ) 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](entity:Vendor) properties and a supported sorter.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/square/vendors/client.rb', line 110 def search(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/vendors/search", 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::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](entity:Vendor) object as a supplier to a seller.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/square/vendors/client.rb', line 157 def update(request_options: {}, **params) _path_param_names = ["vendor_id"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "PUT", path: "v2/vendors/#{params[:vendor_id]}", 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::UpdateVendorResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |