Class: WhopSDK::Resources::Invoices

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Invoices

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 Invoices.

Parameters:



160
161
162
# File 'lib/whop_sdk/resources/invoices.rb', line 160

def initialize(client:)
  @client = client
end

Instance Method Details

#create(collection_method: , company_id: , due_date: , member_id: , plan: , product: , email_address: , product_id: , charge_buyer_fee: nil, customer_name: nil, payment_method_id: nil, payment_token_id: nil, request_options: {}) ⇒ WhopSDK::Models::Invoice

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

Creates an invoice

Required permissions:

  • ‘invoice:create`

  • ‘plan:basic:read`

Parameters:

  • collection_method (Symbol, WhopSDK::Models::CollectionMethod)

    The method of collection for this invoice. If using charge_automatically, you mu

  • company_id (String)

    The company ID to create this invoice for.

  • due_date (Time)

    The date the invoice is due, if applicable.

  • member_id (String)

    The member ID to create this invoice for. Include this if you want to create an

  • plan (WhopSDK::Models::InvoiceCreateParams::Plan)

    The properties of the plan to create for this invoice.

  • product (WhopSDK::Models::InvoiceCreateParams::Product)

    The properties of the product to create for this invoice. Include this if you wa

  • email_address (String)

    The email address to create this invoice for. This is required if you want to cr

  • product_id (String)

    The product ID to create this invoice for. Include this if you want to create an

  • charge_buyer_fee (Boolean, nil)

    Whether or not to charge the customer a buyer fee.

  • customer_name (String, nil)

    The name of the customer to create this invoice for. This is required if you wan

  • payment_method_id (String, nil)

    The payment method ID to use for this invoice. If using charge_automatically, yo

  • payment_token_id (String, nil)

    The payment token ID to use for this invoice. If using charge_automatically, you

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

Returns:

See Also:



47
48
49
50
51
52
53
54
55
56
# File 'lib/whop_sdk/resources/invoices.rb', line 47

def create(params)
  parsed, options = WhopSDK::InvoiceCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "invoices",
    body: parsed,
    model: WhopSDK::Invoice,
    options: options
  )
end

#list(company_id: , after: nil, before: nil, collection_methods: nil, created_after: nil, created_before: nil, direction: nil, first: nil, last: nil, order: nil, product_ids: nil, statuses: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::InvoiceListItem>

Lists invoices

Required permissions:

  • ‘invoice:basic:read`

  • ‘plan:basic:read`

Parameters:

  • company_id (String)

    The ID of the company to list invoices for

  • 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.

  • collection_methods (Array<Symbol, WhopSDK::Models::CollectionMethod>, nil)

    Filter invoices by their collection method

  • created_after (Time, nil)

    The minimum creation date to filter by

  • created_before (Time, nil)

    The maximum creation date to filter by

  • direction (Symbol, WhopSDK::Models::Direction, nil)

    The direction of the sort.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • order (Symbol, WhopSDK::Models::InvoiceListParams::Order, nil)

    Which columns can be used to sort.

  • product_ids (Array<String>, nil)

    Return only invoices created for these specific product ids

  • statuses (Array<Symbol, WhopSDK::Models::InvoiceStatus>, nil)

    The statuses to filter the invoices by

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

Returns:

See Also:



121
122
123
124
125
126
127
128
129
130
131
# File 'lib/whop_sdk/resources/invoices.rb', line 121

def list(params)
  parsed, options = WhopSDK::InvoiceListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "invoices",
    query: parsed,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::InvoiceListItem,
    options: options
  )
end

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

Retrieves an invoice by ID or token

Required permissions:

  • ‘invoice:basic:read`

  • ‘plan:basic:read`

Parameters:

  • id (String)

    The ID of the invoice or a token

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

Returns:

See Also:



74
75
76
77
78
79
80
81
# File 'lib/whop_sdk/resources/invoices.rb', line 74

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

#void(id, request_options: {}) ⇒ Boolean

Void an invoice

Required permissions:

  • ‘invoice:update`

Parameters:

  • id (String)

    The ID of the invoice to void

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

Returns:

  • (Boolean)

See Also:



148
149
150
151
152
153
154
155
# File 'lib/whop_sdk/resources/invoices.rb', line 148

def void(id, params = {})
  @client.request(
    method: :post,
    path: ["invoices/%1$s/void", id],
    model: WhopSDK::Internal::Type::Boolean,
    options: params[:request_options]
  )
end