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:



148
149
150
# File 'lib/whop_sdk/resources/invoices.rb', line 148

def initialize(client:)
  @client = client
end

Instance Method Details

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

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.

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

    The properties of the plan to create for this invoice.

  • 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

  • email_address (String, nil)

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

  • member_id (String, nil)

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

  • payment_token_id (String, nil)

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

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

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

  • product_id (String, nil)

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

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

Returns:

See Also:



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

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

#list(company_id: , after: nil, before: nil, direction: nil, filters: nil, first: nil, last: nil, order: 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.

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

    The direction of the sort.

  • filters (WhopSDK::Models::InvoiceListParams::Filters, nil)

    The filters to apply to the invoices

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

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

Returns:

See Also:



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/whop_sdk/resources/invoices.rb', line 110

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:

Returns:

See Also:



71
72
73
74
75
76
77
78
# File 'lib/whop_sdk/resources/invoices.rb', line 71

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:

Returns:

  • (Boolean)

See Also:



136
137
138
139
140
141
142
143
# File 'lib/whop_sdk/resources/invoices.rb', line 136

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