Class: Square::VendorsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/vendors_api.rb

Overview

VendorsApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

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.

Parameters:

  • body (BulkCreateVendorsRequest)

    Required parameter: An object

Returns:

  • (BulkCreateVendorsResponse Hash)

    response from the API call



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/square/api/vendors_api.rb', line 10

def bulk_create_vendors(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/vendors/bulk-create',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
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.

Parameters:

  • body (BulkRetrieveVendorsRequest)

    Required parameter: An object

Returns:

  • (BulkRetrieveVendorsResponse Hash)

    response from the API call



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/square/api/vendors_api.rb', line 32

def bulk_retrieve_vendors(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/vendors/bulk-retrieve',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
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.

Parameters:

  • body (BulkUpdateVendorsRequest)

    Required parameter: An object

Returns:

  • (BulkUpdateVendorsResponse Hash)

    response from the API call



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/square/api/vendors_api.rb', line 55

def bulk_update_vendors(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/vendors/bulk-update',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
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.

Parameters:

  • body (CreateVendorRequest)

    Required parameter: An object containing

Returns:

  • (CreateVendorResponse Hash)

    response from the API call



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/square/api/vendors_api.rb', line 78

def create_vendor(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/vendors/create',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_vendor(vendor_id:) ⇒ RetrieveVendorResponse Hash

Retrieves the vendor of a specified [Vendor]($m/Vendor) ID. [Vendor](entity:Vendor) to retrieve.

Parameters:

  • vendor_id (String)

    Required parameter: ID of the

Returns:

  • (RetrieveVendorResponse Hash)

    response from the API call



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/square/api/vendors_api.rb', line 122

def retrieve_vendor(vendor_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/vendors/{vendor_id}',
                                 'default')
               .template_param(new_parameter(vendor_id, key: 'vendor_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
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.

Parameters:

  • body (SearchVendorsRequest)

    Required parameter: An object

Returns:

  • (SearchVendorsResponse Hash)

    response from the API call



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/square/api/vendors_api.rb', line 101

def search_vendors(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/vendors/search',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
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.

Parameters:

  • body (UpdateVendorRequest)

    Required parameter: An object containing

  • vendor_id (String)

    Required parameter: Example:

Returns:

  • (UpdateVendorResponse Hash)

    response from the API call



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/square/api/vendors_api.rb', line 144

def update_vendor(body:,
                  vendor_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/v2/vendors/{vendor_id}',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .template_param(new_parameter(vendor_id, key: 'vendor_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end