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:



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:



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

def charges(args = {})
  perform_get_with_objects('/v1/charges', args, AcceptOn::Charge)
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:



49
50
51
# File 'lib/accepton/api/querying.rb', line 49

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:



69
70
71
# File 'lib/accepton/api/querying.rb', line 69

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

#token(id) ⇒ AcceptOn::TransactionToken

Retrieves a transaction token from the API

Parameters:

  • id (String)

    The transaction token identifier

Returns:



81
82
83
# File 'lib/accepton/api/querying.rb', line 81

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