Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Security model. #12

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -4,3 +4,6 @@ rvm:
- 2.0.0
- 2.1.1
- ruby-head
install:
- "gem install bundler"
- "bundle install --jobs=3 --retry=3"
7 changes: 7 additions & 0 deletions lib/figo.rb
Original file line number Diff line number Diff line change
@@ -494,5 +494,12 @@ def submit_payment(payment, tan_scheme_id, state, redirect_uri = nil)
def remove_payment(payment)
query_api "/rest/accounts/#{payment.account_id}/payments/#{payment.payment_id}", nil, "DELETE"
end

# Retrieve securities of all of the user's accounts
#
# @return [Security] an array of `Security` objects
def securities
query_api_object Security, "/rest/securities", nil, "GET", "securities"
end
end
end
95 changes: 94 additions & 1 deletion lib/models.rb
Original file line number Diff line number Diff line change
@@ -43,6 +43,18 @@ def self.dump_attributes
def initialize(session, hash)
@session = session

decnum_keys = %w(
amount balance
credit_line
monthly_spending_limit
quantity
amount
amount_original_currency
exchange_rate
price
purchase_price
)

hash.each do |key, value|
key = key.to_s if key.is_a? Symbol
next unless respond_to? "#{key}="
@@ -52,7 +64,7 @@ def initialize(session, hash)
value = SynchronizationStatus.new(session, value)
elsif key == "balance" and value.is_a? Hash
value = AccountBalance.new(session, value)
elsif key == "amount" or key == "balance" or key == "credit_line" or key == "monthly_spending_limit"
elsif decnum_keys.include? key
value = Flt::DecNum(value.to_s)
elsif key.end_with?("_date")
value = DateTime.iso8601(value)
@@ -463,4 +475,85 @@ class Payment < Base
# @return [String]
attr_accessor :transaction_id
end

# Object representing a depot security
class Security < Base
@dump_attributes = []

# Internal figo Connect security ID
# @return [String]
attr_accessor :security_id

# Internal figo Connect account ID
# @return [String]
attr_accessor :account_id

# Name of the security
# @return [String]
attr_accessor :name

# International Securities Identification Number
# @return [String]
attr_accessor :isin

# Wertpapierkennnummer (if available)
# @return [String]
attr_accessor :wkn

# Market name
# @return [String]
attr_accessor :market

# Three-character currency code when measured in currency (and not pieces)
# @return [String]
attr_accessor :currency

# Number of pieces or value
# @return [Number]
attr_accessor :quantity

# Monetary value in account currency
# @return [Number]
attr_accessor :amount

# Monetary value in trading currency
# @return [Number]
attr_accessor :amount_original_currency

# Exchange rate between trading and account currency
# @return [Number]
attr_accessor :exchange_rate

# Current price
# @return [Number]
attr_accessor :price

# Currency of current price
# @return [String]
attr_accessor :price_currency

# Purchase price
# @return [Number]
attr_accessor :purchase_price

# Currency of purchase price
# @return [String]
attr_accessor :purchase_price_currency

# This flag indicates whether the security has already been marked as visited by the user
# @return [Boolean]
attr_accessor :visited

# Trading timestamp
# @return [String]
attr_accessor :trade_timestamp

# Internal creation timestamp on the figo Connect server
# @return [String]
attr_accessor :creation_timestamp

# Internal modification timestamp on the figo Connect server
# @return [String]
attr_accessor :modification_timestamp
end
end