Class: Unleashed::CurrencyResource

Inherits:
BaseResource show all
Defined in:
lib/unleashed/resources/currency_resource.rb

Overview

Resource for the Currencies API The Currencies resource allows Currencies to be listed, viewed.

Instance Method Summary collapse

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

#allArray<Unleashed::Currency>

List all currencies /Currencies - also returns the first 200 currencies because page number 1 is the default.

Returns:



14
15
16
17
18
19
# File 'lib/unleashed/resources/currency_resource.rb', line 14

def all
  endpoint = 'Currencies'
  response = JSON.parse(@client.get(endpoint).body)
  currencies = response.key?('Items') ? response['Items'] : []
  currencies.map { |attributes| Unleashed::Currency.new(@client, attributes) }
end

#firstUnleashed::Currency

Get a first currency in all

Returns:



24
25
26
# File 'lib/unleashed/resources/currency_resource.rb', line 24

def first
  all.first
end

#lastUnleashed::Currency

Get a last currency in all

Returns:



31
32
33
# File 'lib/unleashed/resources/currency_resource.rb', line 31

def last
  all.last
end

#modelObject



6
7
8
# File 'lib/unleashed/resources/currency_resource.rb', line 6

def model
  Unleashed::Currency
end