pina 0.8.1 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da1d170fdb92e263a0dbdb216abac21588769214
4
- data.tar.gz: f396b6c0025bb1758b24a2a447614c5d368eb791
3
+ metadata.gz: e39da309aa0116522c4409d93ecd7210614e90f9
4
+ data.tar.gz: 32906d34c74d67a52c49fb3b6c197030e67663ef
5
5
  SHA512:
6
- metadata.gz: 13ee83c63c8f8b5b4c4c9ee39dda2287d64676b7c32a2b6e3da948177a82f9b4a6242b5d333f58b9e8d0c31bb9e00d6945c4b2039c3c5f4c48c91ba5f3a38366
7
- data.tar.gz: 18bb2019e379ec506593c8323cd0a6c6f3d6544ab3ac14788ee7c31fe9c2eb8875c02defdc631ff278334ccd105be31d39f3670c5cc4b4bfc70b4447e6f8d5d2
6
+ metadata.gz: 48df18383896fa70ecd5adc18b1960ceddd54b807ebbbbc80464ac618fde58df45e89d8465f03fd9f7017e8fc70ff5a4174a6b8d3ac1b91fd910f32db0002b88
7
+ data.tar.gz: a65f4fe4ed69a858f4c2b888966d272392854d500a0403725da640c7c3d8cd8ba6aaf2b16caca3244636157c7d6fd087b7f4d35e09889119b759dc16418ffebc
data/README.md CHANGED
@@ -220,6 +220,59 @@ Pina::ProcessedDocument.find(gid)
220
220
  Pina::ProcessedDocument.delete(gid)
221
221
  ```
222
222
 
223
+ ### MyBankAccounts
224
+
225
+ #### All my bank accoutns
226
+
227
+ ```ruby
228
+ Pina::MyBankAccount.all
229
+ ```
230
+
231
+ Gets all bank accounts from your database. Results are paginated and you can access
232
+ first, next or previous page like this:
233
+
234
+ ```ruby
235
+ bank_accounts = Pina::MyBankAccount.all
236
+ bank_accounts.next_page
237
+ ```
238
+
239
+ ```ruby
240
+ bank_accounts = Pina::MyBankAccount.all
241
+ bank_accounts.previous_page
242
+
243
+ bank_accounts.first_page
244
+ ```
245
+
246
+ #### Fetching specific bank account
247
+
248
+ ```ruby
249
+ Pina::MyBankAccount.find('csob_czk')
250
+ ```
251
+
252
+ This ID you can find under attribute `bank_account_id`
253
+
254
+
255
+ #### Create new MyBankAccount
256
+
257
+ ```ruby
258
+ params = {
259
+ bank_account: 'XXXXXXXXX/XXXX',
260
+ currency_id: 'CZK',
261
+ bank_account_id: 'XXXX'
262
+ }
263
+
264
+ bank_account = Pina::Models::MyBankAccount.new(params)
265
+ Pina::MyBankAccount.create(bank_account)
266
+ ```
267
+
268
+ #### Update existing bank account
269
+
270
+ ```ruby
271
+ bank_account = Pina::MyBankAccount.find('existing')
272
+ bank_account.download_type = 'none'
273
+ Pina::MyBankAccount.update('existing', bank_account)
274
+ ```
275
+
223
276
  ## Development
224
277
 
225
278
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -16,6 +16,7 @@ require 'pina/rest_adapter'
16
16
  require 'pina/sales_order'
17
17
  require 'pina/receivable'
18
18
  require 'pina/processed_document'
19
+ require 'pina/my_bank_account'
19
20
 
20
21
  module Pina
21
22
  class ConfigurationNotSet < StandardError; end
@@ -0,0 +1,7 @@
1
+ module Pina
2
+ module Collections
3
+ class MyBankAccount < Base
4
+ attribute :items, Array[::Pina::Models::MyBankAccount]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,62 @@
1
+ module Pina
2
+ module Models
3
+ class MyBankAccount
4
+ include Virtus.model
5
+
6
+ attribute :created_at
7
+ attribute :updated_at
8
+ attribute :creator
9
+ attribute :creator_id
10
+ attribute :modifier
11
+ attribute :modifier_id
12
+ attribute :opening_balance_date
13
+ attribute :bank_account
14
+ attribute :bank_account_id
15
+ attribute :bank_code
16
+ attribute :country
17
+ attribute :country_id
18
+ attribute :currency
19
+ attribute :currency_id
20
+ attribute :statement_download_interval
21
+ attribute :statement_download_type
22
+ attribute :order_type
23
+ attribute :statement_encoding
24
+ attribute :external_id
25
+ attribute :statement_type
26
+ attribute :iban
27
+ attribute :default
28
+ attribute :hidden
29
+ attribute :officially_published
30
+ attribute :send_order_to_bank
31
+ attribute :download_type
32
+
33
+ def creator=(value)
34
+ return unless value
35
+
36
+ self.creator_id = value.values[0]
37
+ super
38
+ end
39
+
40
+ def modifier=(value)
41
+ return unless value
42
+
43
+ self.modifier_id = value.values[0]
44
+ super
45
+ end
46
+
47
+ def country=(value)
48
+ return unless value
49
+
50
+ self.country_id = value.values[0]
51
+ super
52
+ end
53
+
54
+ def currency=(value)
55
+ return unless value
56
+
57
+ self.currency_id = value.values[0]
58
+ super
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,63 @@
1
+ require 'pina/models/my_bank_account'
2
+ require 'pina/collections/my_bank_account'
3
+
4
+ module Pina
5
+ class MyBankAccount
6
+ class << self
7
+ def new(params = nil)
8
+ Pina::Models::MyBankAccount.new(params)
9
+ end
10
+
11
+ def find(id)
12
+ response = Pina::RestAdapter.get(:my_bank_accounts, id)
13
+
14
+ return Pina::Models::MyBankAccount.new(attributes(response)) if
15
+ response.ok?
16
+
17
+ response
18
+ end
19
+
20
+ def all(page = nil)
21
+ response = Pina::RestAdapter.get(:my_bank_accounts, page)
22
+
23
+ return Pina::Collections::MyBankAccount.new(attributes(response)) if
24
+ response.ok?
25
+
26
+ response
27
+ end
28
+
29
+ def where(hash, page = nil)
30
+ response = Pina::RestAdapter.get(:my_bank_accounts, hash)
31
+
32
+ return Pina::Collections::MyBankAccount.new(attributes(response)) if
33
+ response.ok?
34
+
35
+ response
36
+ end
37
+
38
+ def create(my_bank_account)
39
+ response = Pina::RestAdapter.post(:my_bank_accounts, my_bank_account)
40
+
41
+ return Pina::Models::MyBankAccount.new(attributes(response)) if
42
+ response.ok?
43
+
44
+ response
45
+ end
46
+
47
+ def update(id, my_bank_account)
48
+ response = Pina::RestAdapter.patch(:my_bank_accounts, id, my_bank_account)
49
+
50
+ return Pina::Models::MyBankAccount.new(attributes(response)) if
51
+ response.ok?
52
+
53
+ response
54
+ end
55
+
56
+ private
57
+
58
+ def attributes(response)
59
+ response.to_hash.merge(response: response)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -1,3 +1,3 @@
1
1
  module Pina
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Hronek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-10 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -213,6 +213,7 @@ files:
213
213
  - lib/pina.rb
214
214
  - lib/pina/collections/base.rb
215
215
  - lib/pina/collections/contact.rb
216
+ - lib/pina/collections/my_bank_account.rb
216
217
  - lib/pina/collections/processed_document.rb
217
218
  - lib/pina/collections/receivable.rb
218
219
  - lib/pina/collections/sales_invoice.rb
@@ -220,11 +221,13 @@ files:
220
221
  - lib/pina/contact.rb
221
222
  - lib/pina/models/address.rb
222
223
  - lib/pina/models/contact.rb
224
+ - lib/pina/models/my_bank_account.rb
223
225
  - lib/pina/models/processed_document.rb
224
226
  - lib/pina/models/receivable.rb
225
227
  - lib/pina/models/sales_invoice.rb
226
228
  - lib/pina/models/sales_item.rb
227
229
  - lib/pina/models/sales_order.rb
230
+ - lib/pina/my_bank_account.rb
228
231
  - lib/pina/processed_document.rb
229
232
  - lib/pina/receivable.rb
230
233
  - lib/pina/rest_adapter.rb