Class: Io::Flow::V0::Models::Rate

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Represents an organization-specific currency conversion rate at a point in time.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Rate

Returns a new instance of Rate.



56875
56876
56877
56878
56879
56880
56881
56882
56883
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56875

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :base, :target, :effective_at, :value], 'Rate')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @base = HttpClient::Preconditions.assert_class('base', opts.delete(:base), String)
  @target = HttpClient::Preconditions.assert_class('target', opts.delete(:target), String)
  @effective_at = HttpClient::Preconditions.assert_class('effective_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:effective_at)), DateTime)
  @value = HttpClient::Preconditions.assert_class('value', HttpClient::Helper.to_big_decimal(opts.delete(:value)), BigDecimal)
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



56873
56874
56875
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56873

def base
  @base
end

#effective_atObject (readonly)

Returns the value of attribute effective_at.



56873
56874
56875
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56873

def effective_at
  @effective_at
end

#idObject (readonly)

Returns the value of attribute id.



56873
56874
56875
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56873

def id
  @id
end

#targetObject (readonly)

Returns the value of attribute target.



56873
56874
56875
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56873

def target
  @target
end

#valueObject (readonly)

Returns the value of attribute value.



56873
56874
56875
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56873

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



56889
56890
56891
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56889

def copy(incoming={})
  Rate.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



56893
56894
56895
56896
56897
56898
56899
56900
56901
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56893

def to_hash
  {
    :id => id,
    :base => base,
    :target => target,
    :effective_at => effective_at,
    :value => value.to_f.to_s
  }
end

#to_jsonObject



56885
56886
56887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56885

def to_json
  JSON.dump(to_hash)
end