Class: Square::VendorsApi
- Defined in:
- lib/square/api/vendors_api.rb
Overview
VendorsApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#bulk_create_vendors(body:) ⇒ BulkCreateVendorsResponse Hash
Creates one or more [Vendor]($m/Vendor) objects to represent suppliers to a seller.
-
#bulk_retrieve_vendors(body:) ⇒ BulkRetrieveVendorsResponse Hash
Retrieves one or more vendors of specified [Vendor]($m/Vendor) IDs.
-
#bulk_update_vendors(body:) ⇒ BulkUpdateVendorsResponse Hash
Updates one or more of existing [Vendor]($m/Vendor) objects as suppliers to a seller.
-
#create_vendor(body:) ⇒ CreateVendorResponse Hash
Creates a single [Vendor]($m/Vendor) object to represent a supplier to a seller.
-
#initialize(config, http_call_back: nil) ⇒ VendorsApi
constructor
A new instance of VendorsApi.
-
#retrieve_vendor(vendor_id:) ⇒ RetrieveVendorResponse Hash
Retrieves the vendor of a specified [Vendor]($m/Vendor) ID.
-
#search_vendors(body:) ⇒ SearchVendorsResponse Hash
Searches for vendors using a filter against supported [Vendor]($m/Vendor) properties and a supported sorter.
-
#update_vendor(body:, vendor_id:) ⇒ UpdateVendorResponse Hash
Updates an existing [Vendor]($m/Vendor) object as a supplier to a seller.
Methods inherited from BaseApi
#execute_request, #get_user_agent, #validate_parameters
Constructor Details
#initialize(config, http_call_back: nil) ⇒ VendorsApi
Returns a new instance of VendorsApi.
4 5 6 |
# File 'lib/square/api/vendors_api.rb', line 4 def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end |
Instance Method Details
#bulk_create_vendors(body:) ⇒ BulkCreateVendorsResponse Hash
Creates one or more [Vendor]($m/Vendor) objects to represent suppliers to a seller. containing the fields to POST for the request. See the corresponding object definition for field details.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/square/api/vendors_api.rb', line 14 def bulk_create_vendors(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/vendors/bulk-create' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#bulk_retrieve_vendors(body:) ⇒ BulkRetrieveVendorsResponse Hash
Retrieves one or more vendors of specified [Vendor]($m/Vendor) IDs. containing the fields to POST for the request. See the corresponding object definition for field details.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/square/api/vendors_api.rb', line 48 def bulk_retrieve_vendors(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/vendors/bulk-retrieve' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#bulk_update_vendors(body:) ⇒ BulkUpdateVendorsResponse Hash
Updates one or more of existing [Vendor]($m/Vendor) objects as suppliers to a seller. containing the fields to POST for the request. See the corresponding object definition for field details.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/square/api/vendors_api.rb', line 83 def bulk_update_vendors(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/vendors/bulk-update' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.put( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#create_vendor(body:) ⇒ CreateVendorResponse Hash
Creates a single [Vendor]($m/Vendor) object to represent a supplier to a seller. the fields to POST for the request. See the corresponding object definition for field details.
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 |
# File 'lib/square/api/vendors_api.rb', line 118 def create_vendor(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/vendors/create' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#retrieve_vendor(vendor_id:) ⇒ RetrieveVendorResponse Hash
Retrieves the vendor of a specified [Vendor]($m/Vendor) ID. [Vendor]($m/Vendor) to retrieve.
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/square/api/vendors_api.rb', line 186 def retrieve_vendor(vendor_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/vendors/{vendor_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'vendor_id' => { 'value' => vendor_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#search_vendors(body:) ⇒ SearchVendorsResponse Hash
Searches for vendors using a filter against supported [Vendor]($m/Vendor) properties and a supported sorter. containing the fields to POST for the request. See the corresponding object definition for field details.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/square/api/vendors_api.rb', line 153 def search_vendors(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/vendors/search' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#update_vendor(body:, vendor_id:) ⇒ UpdateVendorResponse Hash
Updates an existing [Vendor]($m/Vendor) object as a supplier to a seller. the fields to POST for the request. See the corresponding object definition for field details.
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 249 250 251 252 253 254 255 |
# File 'lib/square/api/vendors_api.rb', line 223 def update_vendor(body:, vendor_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/vendors/{vendor_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'vendor_id' => { 'value' => vendor_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.put( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |