Class: WhopSDK::Resources::Shipments

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/shipments.rb

Overview

Shipments

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Shipments

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Shipments.

Parameters:



112
113
114
# File 'lib/whop_sdk/resources/shipments.rb', line 112

def initialize(client:)
  @client = client
end

Instance Method Details

#create(company_id:, payment_id:, tracking_code:, request_options: {}) ⇒ WhopSDK::Models::Shipment

Some parameter documentations has been truncated, see Models::ShipmentCreateParams for more details.

Create a new shipment with a tracking code for a specific payment within a company.

Required permissions:

  • ‘shipment:create`

  • ‘payment:basic:read`

Parameters:

  • company_id (String)

    The unique identifier of the company to create the shipment for, starting with ‘

  • payment_id (String)

    The unique identifier of the payment to associate the shipment with.

  • tracking_code (String)

    The carrier tracking code for the shipment, such as a USPS, UPS, or FedEx tracki

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
# File 'lib/whop_sdk/resources/shipments.rb', line 31

def create(params)
  parsed, options = WhopSDK::ShipmentCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "shipments",
    body: parsed,
    model: WhopSDK::Shipment,
    options: options
  )
end

#list(after: nil, before: nil, company_id: nil, first: nil, last: nil, payment_id: nil, user_id: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::ShipmentListResponse>

Returns a paginated list of shipments, with optional filtering by payment, company, or user.

Required permissions:

  • ‘shipment:basic:read`

  • ‘payment:basic:read`

Parameters:

  • after (String, nil)

    Returns the elements in the list that come after the specified cursor.

  • before (String, nil)

    Returns the elements in the list that come before the specified cursor.

  • company_id (String, nil)

    Filter shipments to only those belonging to this company.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • payment_id (String, nil)

    Filter shipments to only those associated with this specific payment.

  • user_id (String, nil)

    Filter shipments to only those for this specific user.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/whop_sdk/resources/shipments.rb', line 96

def list(params = {})
  parsed, options = WhopSDK::ShipmentListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "shipments",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::ShipmentListResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::Shipment

Retrieves the details of an existing shipment.

Required permissions:

  • ‘shipment:basic:read`

  • ‘payment:basic:read`

Parameters:

  • id (String)

    The unique identifier of the shipment to retrieve.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



58
59
60
61
62
63
64
65
# File 'lib/whop_sdk/resources/shipments.rb', line 58

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["shipments/%1$s", id],
    model: WhopSDK::Shipment,
    options: params[:request_options]
  )
end