Class: TwentySix::Core
- Inherits:
-
Object
- Object
- TwentySix::Core
- Includes:
- HTTParty
- Defined in:
- lib/twentysix/core.rb
Class Method Summary collapse
Instance Method Summary collapse
- #account_summary ⇒ Object
- #addresses ⇒ Object
- #barzahlen_summary ⇒ Object
- #block_card(card_id) ⇒ Object
- #card_limits(card_id) ⇒ Object
- #card_with_id(id) ⇒ Object
- #cards ⇒ Object
- #categories ⇒ Object
- #contacts ⇒ Object
- #create_transfer(pin, name, iban, bic, amount, reference) ⇒ Object
-
#initialize(access_token) ⇒ Core
constructor
A new instance of Core.
- #statement(id, pdf: false) ⇒ Object
- #statements ⇒ Object
- #transaction(id) ⇒ Object
- #transaction_metadata(smartlink_id) ⇒ Object
- #transactions(count: 50, include_pending: false, text_filter: nil, from_time: nil, to_time: nil) ⇒ Object
- #unblock_card(card_id) ⇒ Object
- #update_card_limits(card_id, limits) ⇒ Object
- #whoami ⇒ Object
Constructor Details
#initialize(access_token) ⇒ Core
Returns a new instance of Core.
26 27 28 |
# File 'lib/twentysix/core.rb', line 26 def initialize(access_token) @access_token = access_token end |
Class Method Details
.authenticate(username, password) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/twentysix/core.rb', line 8 def self.authenticate(username, password) response = post('/oauth/token', body: { 'username' => username, 'password' => password, 'grant_type' => 'password' }, headers: { 'Authorization' => 'Basic bXktdHJ1c3RlZC13ZHBDbGllbnQ6c2VjcmV0', 'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36' }) if response['access_token'] new(response['access_token']) else response end end |
Instance Method Details
#account_summary ⇒ Object
34 35 36 |
# File 'lib/twentysix/core.rb', line 34 def account_summary get '/api/accounts' end |
#addresses ⇒ Object
38 39 40 |
# File 'lib/twentysix/core.rb', line 38 def addresses get '/api/addresses' end |
#barzahlen_summary ⇒ Object
124 125 126 |
# File 'lib/twentysix/core.rb', line 124 def get '/api/barzahlen/check' end |
#block_card(card_id) ⇒ Object
128 129 130 |
# File 'lib/twentysix/core.rb', line 128 def block_card(card_id) post "/api/cards/#{card_id}/block" end |
#card_limits(card_id) ⇒ Object
58 59 60 |
# File 'lib/twentysix/core.rb', line 58 def card_limits(card_id) get "/api/settings/limits/#{card_id}" end |
#card_with_id(id) ⇒ Object
50 51 52 |
# File 'lib/twentysix/core.rb', line 50 def card_with_id(id) get "/api/cards/#{id}" end |
#cards ⇒ Object
54 55 56 |
# File 'lib/twentysix/core.rb', line 54 def cards get '/api/cards' end |
#categories ⇒ Object
46 47 48 |
# File 'lib/twentysix/core.rb', line 46 def categories get '/api/smrt/categories' end |
#contacts ⇒ Object
42 43 44 |
# File 'lib/twentysix/core.rb', line 42 def contacts get '/api/smrt/contacts' end |
#create_transfer(pin, name, iban, bic, amount, reference) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/twentysix/core.rb', line 107 def create_transfer(pin, name, iban, bic, amount, reference) post '/api/transactions', options: { body: { pin: pin, transaction: { partnerName: name, partnerBic: bic, partnerIban: iban, amount: amount, referenceText: reference, type: 'DT' } }.to_json, headers: { 'Content-Type' => 'application/json' } } end |
#statement(id, pdf: false) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/twentysix/core.rb', line 70 def statement(id, pdf: false) prefix = if pdf '' else 'json/' end get "/api/statements/#{prefix}#{id}", options: { headers: { 'Content-Type' => 'application/json' } } end |
#statements ⇒ Object
66 67 68 |
# File 'lib/twentysix/core.rb', line 66 def statements get '/api/statements' end |
#transaction(id) ⇒ Object
99 100 101 |
# File 'lib/twentysix/core.rb', line 99 def transaction(id) get "/api/transactions/#{id}" end |
#transaction_metadata(smartlink_id) ⇒ Object
103 104 105 |
# File 'lib/twentysix/core.rb', line 103 def (smartlink_id) get "/api/transactions/#{smartlink_id}/metadata" end |
#transactions(count: 50, include_pending: false, text_filter: nil, from_time: nil, to_time: nil) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/twentysix/core.rb', line 79 def transactions(count: 50, include_pending: false, text_filter: nil, from_time: nil, to_time: nil) query = { limit: count, pending: include_pending } if from_time && to_time query['from'] = from_time.to_i query['to'] = to_time.to_i end query['textFilter'] = text_filter if text_filter get '/api/smrt/transactions', options: { query: query } end |
#unblock_card(card_id) ⇒ Object
132 133 134 |
# File 'lib/twentysix/core.rb', line 132 def unblock_card(card_id) post "/api/cards/#{card_id}/unblock" end |
#update_card_limits(card_id, limits) ⇒ Object
62 63 64 |
# File 'lib/twentysix/core.rb', line 62 def update_card_limits(card_id, limits) post "/api/settings/limits/#{card_id}", options: { body: limits } end |
#whoami ⇒ Object
30 31 32 |
# File 'lib/twentysix/core.rb', line 30 def whoami get '/api/me' end |