Class: VoucherifySdk::OrdersApi

Inherits:
Object
  • Object
show all
Defined in:
lib/VoucherifySdk/api/orders_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ OrdersApi

Returns a new instance of OrdersApi.



19
20
21
# File 'lib/VoucherifySdk/api/orders_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/VoucherifySdk/api/orders_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_order(opts = {}) ⇒ OrdersCreateResponseBody

Create Order Creates an order object and triggers an order creation event. 📘 Upsert Mode If you pass an id or a source_id that already exists in the order database, Voucherify will return a related order object with updated fields.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



27
28
29
30
# File 'lib/VoucherifySdk/api/orders_api.rb', line 27

def create_order(opts = {})
  data, _status_code, _headers = create_order_with_http_info(opts)
  data
end

#create_order_export(opts = {}) ⇒ OrdersExportCreateResponseBody

Create Orders Export Creates a downloadable CSV file containing a list of orders. The parameters listed in the payload resembles headers in the CSV file. To include a parameter to the file, add it to the parameters.fields object in the request body. The available filters are all order object attributes. Additionally, any metadata defined in the metadata schema can be exported. Passing an empty JSON will generate a file containing three default fields: id, source_id, and status. The fields array is an array of strings containing the data in the export. These fields define the headers in the CSV file. The array can be a combination of any of the following available fields:

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



91
92
93
94
# File 'lib/VoucherifySdk/api/orders_api.rb', line 91

def create_order_export(opts = {})
  data, _status_code, _headers = create_order_export_with_http_info(opts)
  data
end

#get_order(order_id, opts = {}) ⇒ OrdersGetResponseBody

Get Order Retrieve an order.

Parameters:

  • order_id (String)

    Unique Voucherify order ID or order source ID.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



155
156
157
158
# File 'lib/VoucherifySdk/api/orders_api.rb', line 155

def get_order(order_id, opts = {})
  data, _status_code, _headers = get_order_with_http_info(order_id, opts)
  data
end

#import_orders(opts = {}) ⇒ OrdersImportCreateResponseBody

Import Orders

🚧 Historical orders  This endpoint should only be used to import historical orders into Voucherify. For on-going synchronization, the create order and update order endpoints should be used. This is critical because this endpoint does not store events or launch distributions. # Limitations ## Import volume There can be only a single on-going order import per tenant per project at a given time. The user can schedule more imports but those extra imports will be scheduled to run in sequence one by one.   ## Maximum count of orders in single import There is a 2000 limit but we might decide to change it to a lower / higher value at any given time depending if we find this value is too high or too low with time. # Notifications There are no notifications on the Dashboard because this import is launched via the API. # Triggered actions    If you import orders with customers, then a logic will be scheduled responsible for placing these customers into segments and refreshing the segments summary. Consequently, this update will trigger  - **customers entering into segments**  - **distributions** based on any rules tied to customer entering segment(s) - **earning rules** based on the customer entering segment(s) # What is not triggered 1. No webhooks are triggered during the import of orders - for both orders and upserted products / skus.   2. Distributions based on Order Update, Order Paid, Order Created and Order Cancelled. In other words if you have a distribution based on Order Paid and you import an order with a PAID status, the distribution is not going to be triggered.     3. No events are created during the import of orders - for both orders and upserted products / skus. In other words you wont see any events in the Activity tab in the Dashboard such as Order created or Order paid. If you are additionally upserting products / skus, then you wont see the Product created events listed, etc.    4. Earning rules based on Order Paid wont be triggered. This API request starts a process that affects Voucherify data in bulk.  In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window.  The result will return the async ID. You can verify the status of your request via this API request.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



218
219
220
221
# File 'lib/VoucherifySdk/api/orders_api.rb', line 218

def import_orders(opts = {})
  data, _status_code, _headers = import_orders_with_http_info(opts)
  data
end

#list_orders(opts = {}) ⇒ OrdersListResponseBody

List Orders Returns a list of orders.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    A limit on the number of objects to be returned. Limit can range between 1 and 100 items.

  • :page (Integer)

    Which page of results to return.

  • :order (ParameterOrderListOrders)

    This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order.

Returns:



284
285
286
287
# File 'lib/VoucherifySdk/api/orders_api.rb', line 284

def list_orders(opts = {})
  data, _status_code, _headers = list_orders_with_http_info(opts)
  data
end

#update_order(order_id, opts = {}) ⇒ OrdersUpdateResponseBody

Update Order Updates the specified order by setting the values of the parameters passed in the request body. Any parameters not provided will be left unchanged.

Parameters:

  • order_id (String)

    Unique Voucherify order ID or order source ID.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :orders_update_request_body (OrdersUpdateRequestBody)

    Specify the parameters of the order that are to be updated.

Returns:



361
362
363
364
# File 'lib/VoucherifySdk/api/orders_api.rb', line 361

def update_order(order_id, opts = {})
  data, _status_code, _headers = update_order_with_http_info(order_id, opts)
  data
end