Module: AcceptOn::API::Querying

Includes:
Utils
Included in:
Client
Defined in:
lib/accepton/api/querying.rb

Instance Method Summary collapse

Instance Method Details

#charge(id) ⇒ AcceptOn::Charge

Retrieves a charge from the API

Parameters:

  • id (String)

    The charge identifier

Returns:

Raises:



16
17
18
# File 'lib/accepton/api/querying.rb', line 16

def charge(id)
  perform_get_with_object("/v1/charges/#{id}", {}, AcceptOn::Charge)
end

#charges(args = {}) ⇒ AcceptOn::Charge

Retrieves a page of charges from the API

Parameters:

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

    A hash of query parameters

Options Hash (args):

  • :end_date (DateTime, String)

    The latest data/time for the objects to be created on.

  • :start_date (DateTime, String)

    The earliest date/time for the objects to be created on.

  • :order (String)

    The order to sort by (asc or desc).

  • :order_by (String)

    The field to order by (e.g. created_at).

Returns:

Raises:



34
35
36
# File 'lib/accepton/api/querying.rb', line 34

def charges(args = {})
  perform_get_with_objects('/v1/charges', args, AcceptOn::Charge)
end

#plan(id) ⇒ AcceptOn::Plan

Retrieves a plan from the API

Parameters:

  • id (String)

    The plan identifier

Returns:

Raises:



46
47
48
# File 'lib/accepton/api/querying.rb', line 46

def plan(id)
  perform_get_with_object("/v1/plans/#{id}", {}, AcceptOn::Plan)
end

#plans(args = {}) ⇒ AcceptOn::Plan

Retrieves a list of all plans from the API

Parameters:

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

    A hash of query parameters

Options Hash (args):

  • :order (String)

    The order to sort by (asc or desc).

  • :order_by (String)

    The field to order by (e.g. created_at).

  • :page (Integer)

    The page number to retrieve.

  • :per_page (Integer)

    The size of the page to retrieve (max: 100).

  • :period_unit (String, Symbol)

    The period unit to filter by.

Returns:

Raises:



63
64
65
# File 'lib/accepton/api/querying.rb', line 63

def plans(args = {})
  perform_get_with_objects('/v1/plans', args, AcceptOn::Plan)
end

#promo_code(name) ⇒ AcceptOn::PromoCode

Retrieves a promo code from AcceptOn

Examples:

Retrieves the promo code with the name "20OFF"

client.promo_code('20OFF')

Parameters:

  • name (String)

    The name of the promo code to retrieve.

Returns:

Raises:



108
109
110
# File 'lib/accepton/api/querying.rb', line 108

def promo_code(name)
  perform_get_with_object("/v1/promo_codes/#{name}", {}, AcceptOn::PromoCode)
end

#promo_codes(args = {}) ⇒ Array<AcceptOn::PromoCode>

Retrieves a page of promo codes from AcceptOn

Examples:

Retrieves the most recently created promo codes on the account

client.promo_codes

Parameters:

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

    A hash of query parameters

Options Hash (args):

  • :order (String)

    The order to sort by (asc or desc).

  • :order_by (String)

    The field to order by (e.g. created_at).

  • :page (Integer)

    The page number to retrieve.

  • :per_page (Integer)

    The size of the page to retrieve (max: 100).

  • :promo_type (String, Symbol)

    The type of promo code to filter by.

Returns:

Raises:



128
129
130
# File 'lib/accepton/api/querying.rb', line 128

def promo_codes(args = {})
  perform_get_with_objects('/v1/promo_codes', args, AcceptOn::PromoCode)
end

#subscription(id) ⇒ AcceptOn::Subscription

Retrieves a subscription from AcceptOn

Parameters:

  • id (String)

    The subscription identifier.

Returns:

Raises:



75
76
77
# File 'lib/accepton/api/querying.rb', line 75

def subscription(id)
  perform_get_with_object("/v1/subscriptions/#{id}", {}, AcceptOn::Subscription)
end

#subscriptions(args = {}) ⇒ AcceptOn::Subscription

Retrieves a page of subscriptions from AcceptOn

Parameters:

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

    A hash of query parameters

Options Hash (args):

  • :order (String)

    The order to sort by (asc or desc).

  • :order_by (String)

    The field to order by (e.g. created_at).

  • :page (Integer)

    The page number to retrieve.

  • :per_page (Integer)

    The size of the page to retrieve (max: 100).

  • :active (Boolean)

    The activity status of the subscription to filter by.

  • 'plan.token' (String)

    The plan id of the subscription to filter by.

Returns:

Raises:



93
94
95
# File 'lib/accepton/api/querying.rb', line 93

def subscriptions(args = {})
  perform_get_with_objects('/v1/subscriptions', args, AcceptOn::Subscription)
end

#token(id) ⇒ AcceptOn::TransactionToken

Retrieves a transaction token from the API

Parameters:

  • id (String)

    The transaction token identifier

Returns:

Raises:



140
141
142
# File 'lib/accepton/api/querying.rb', line 140

def token(id)
  perform_get_with_object("/v1/tokens/#{id}", {}, AcceptOn::TransactionToken)
end