Class: Unleashed::PaymentTermResource
- Inherits:
-
BaseResource
- Object
- BaseResource
- Unleashed::PaymentTermResource
- Defined in:
- lib/unleashed/resources/payment_term_resource.rb
Overview
Resource for the PaymentTerms API The PaymentTerms resource allows PaymentTerms to be listed.
Instance Method Summary collapse
-
#all ⇒ Array<Unleashed::PaymentTerm>
List all payment_terms /PaymentTerms - also returns the first 200 payment_terms because page number 1 is the default.
-
#first ⇒ Unleashed::PaymentTerm
Get a first payment_term in all.
-
#last ⇒ Unleashed::PaymentTerm
Get a last payment_term in all.
- #model ⇒ Object
Methods inherited from BaseResource
#initialize, #method_missing, #respond_to?
Constructor Details
This class inherits a constructor from Unleashed::BaseResource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Unleashed::BaseResource
Instance Method Details
#all ⇒ Array<Unleashed::PaymentTerm>
List all payment_terms /PaymentTerms - also returns the first 200 payment_terms because page number 1 is the default.
{
"Items": [
{
"Guid": "6223b37e-2ee4-41ed-a215-5f14c53e8f7f",
"Type": "DaysOfTheMonthFollowing",
"Days": 20,
"Obsolete": false,
"PaymentTermDescription": "20th Month following"
},
{
"Guid": "6488bee4-ea4c-4a25-ba1b-a86965120e34",
"Type": "DaysOfTheMonthFollowing",
"Days": 25,
"Obsolete": false,
"PaymentTermDescription": "25th Month following"
}
]
}
33 34 35 36 37 38 |
# File 'lib/unleashed/resources/payment_term_resource.rb', line 33 def all endpoint = 'PaymentTerms' response = JSON.parse(@client.get(endpoint).body) payment_terms = response.key?('Items') ? response['Items'] : [] payment_terms.map { |attributes| Unleashed::PaymentTerm.new(@client, attributes) } end |
#first ⇒ Unleashed::PaymentTerm
Get a first payment_term in all
43 44 45 |
# File 'lib/unleashed/resources/payment_term_resource.rb', line 43 def first all.first end |
#last ⇒ Unleashed::PaymentTerm
Get a last payment_term in all
50 51 52 |
# File 'lib/unleashed/resources/payment_term_resource.rb', line 50 def last all.last end |
#model ⇒ Object
7 8 9 |
# File 'lib/unleashed/resources/payment_term_resource.rb', line 7 def model Unleashed::PaymentTerm end |