Class: Brightpearl::Currency

Inherits:
Resource show all
Defined in:
lib/brightpearl/resources/currency.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

send_request, to_query

Constructor Details

#initialize(ara) ⇒ Currency

ARA => API Record Array



17
18
19
20
21
22
23
24
25
# File 'lib/brightpearl/resources/currency.rb', line 17

def initialize(ara)
  @id                                    = ara[0]
  @title                                 = ara[1]
  @code                                  = ara[2]
  @symbol                                = ara[3]
  @exchange_rate                         = ara[4]
  @is_default                            = ara[5]
  @exchange_rate_variance_nominal_code   = ara[6]
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



3
4
5
# File 'lib/brightpearl/resources/currency.rb', line 3

def code
  @code
end

#exchange_rateObject

Returns the value of attribute exchange_rate.



3
4
5
# File 'lib/brightpearl/resources/currency.rb', line 3

def exchange_rate
  @exchange_rate
end

#exchange_rate_variance_nominal_codeObject

Returns the value of attribute exchange_rate_variance_nominal_code.



3
4
5
# File 'lib/brightpearl/resources/currency.rb', line 3

def exchange_rate_variance_nominal_code
  @exchange_rate_variance_nominal_code
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/brightpearl/resources/currency.rb', line 3

def id
  @id
end

#is_defaultObject

Returns the value of attribute is_default.



3
4
5
# File 'lib/brightpearl/resources/currency.rb', line 3

def is_default
  @is_default
end

#symbolObject

Returns the value of attribute symbol.



3
4
5
# File 'lib/brightpearl/resources/currency.rb', line 3

def symbol
  @symbol
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/brightpearl/resources/currency.rb', line 3

def title
  @title
end

Class Method Details

.search(query_params = {}) ⇒ Object



8
9
10
11
12
13
# File 'lib/brightpearl/resources/currency.rb', line 8

def search(query_params = {})
  response = send_request(path: "accounting-service/currency-search?#{to_query(query_params)}", method: :get)
  response.merge({
    records: response[:payload]["response"]["results"].map { |item| Currency.new(item) }
  })
end