fio_api 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13a5ab858a6e9b441eb53773dbe28611e6754bf2
4
- data.tar.gz: 9c9d9e3089fdd10c092d3ecfee8c35d17a2fdeb8
3
+ metadata.gz: 886ed6df6b92f3fda8e544c1a92d409b0d63e771
4
+ data.tar.gz: 5254de00eeb387619475d8a5fcdb4a9f1e8ebe02
5
5
  SHA512:
6
- metadata.gz: e19bf77982f36c837797367f617c7a66d2a4ae0ea29fb9888071f4965ff47469c6bdff10983d17fe034d13589ffeb6463ab85464eaaf09b77355f7a51935a9ae
7
- data.tar.gz: 56c4ea9d17bb41eb1120998d1bfc7d60853f64c9fecfba7e4ac63b5a291b13bfc4690d424284bcda59cae0eec883fef5920de0fc867d262bfa255a6dacd01ed1
6
+ metadata.gz: a3d88c90b4e1b54b33c80ceaa85586e0e2455e2943a87600486a428f60bd14ca20c23febfb049d966f7aa9baaf9354d84a28358d3d3b5128556fda9f371adb19
7
+ data.tar.gz: 8998e7992115cae5c652ed7633439815cc65a4fedf971554f6854520d82bd5bde55cb2577ef739388ab644f07cb56f378e9394249d6351074252b6dd2a704b71
@@ -19,9 +19,14 @@ This gem is a wrapper for Fio bank API.
19
19
  list.by_date_range(Date.new(2012,11,05), Date.new(2012,12,26)) # Specify listing condition and fetch request
20
20
  list.response # Return deserialized response
21
21
 
22
+ === Request to get transactions form last request
23
+ list = FioAPI::List.new
24
+ list.from_last_fetch
25
+ list.response
26
+
22
27
  === Request transactions by listing_id and year
23
28
  list = FioAPI::List.new
24
- list.by_listing_id_and_year("43XC6362ASD", 2012)
29
+ list.by_listing_id_and_year(1, 2012)
25
30
  list.response
26
31
 
27
32
  === Request to set last request id
@@ -35,10 +40,12 @@ This gem is a wrapper for Fio bank API.
35
40
  list.response
36
41
 
37
42
  === Import domestic payments for authorization
38
- domestic = FioAPI::Payments::Domestic.new(***) # Create new payment
39
- service = FioAPI::Payment.new domestic # Pass one payment or array of payments
43
+ payment = FioAPI::Payments::Domestic.new(:account_from, :currency, :amount, :account_to,
44
+ :bank_code, :ks, :vs, :ss, :date, :message_for_recipient, :comment)
45
+ service = FioAPI::Payment.new [payment] # Pass one payment or array of payments
40
46
  service.import # Call API
41
47
  service.response # Return deserialized response with status code etc.
48
+ service.success? # => true / false
42
49
 
43
50
  == Contributing to fio_api
44
51
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: fio_api 0.0.6 ruby lib
5
+ # stub: fio_api 0.0.7 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "fio_api".freeze
9
- s.version = "0.0.6"
9
+ s.version = "0.0.7"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Robin Bortlik".freeze, "Adam Martinik".freeze]
14
- s.date = "2018-06-04"
14
+ s.date = "2018-06-06"
15
15
  s.description = "API wrapper for FIO bank".freeze
16
16
  s.email = "a.martinik@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -58,8 +58,10 @@ Gem::Specification.new do |s|
58
58
  "spec/fixtures/vcr_cassettes/from_last_fetch.yml",
59
59
  "spec/fixtures/vcr_cassettes/import.yml",
60
60
  "spec/fixtures/vcr_cassettes/invalid_import.yml",
61
+ "spec/fixtures/vcr_cassettes/old_import.yml",
61
62
  "spec/fixtures/vcr_cassettes/set_last_fetch_date.yml",
62
63
  "spec/fixtures/vcr_cassettes/set_last_fetch_id.yml",
64
+ "spec/fixtures/vcr_cassettes/wrong_token_import.yml",
63
65
  "spec/spec_helper.rb",
64
66
  "spec/utils/hash_spec.rb"
65
67
  ]
@@ -39,6 +39,7 @@ module FioAPI
39
39
  # == Returns:
40
40
  # Status
41
41
  def deserialize_import(response_json)
42
+ return FioAPI::Payments::Status.new(error_code: 500) unless response_json
42
43
  FioAPI::Payments::Status.new(
43
44
  error_code: response_json.try_path('errorCode').to_i,
44
45
  error_message: response_json.try_path('message').to_s,
@@ -17,6 +17,10 @@ module FioAPI
17
17
  self.request
18
18
  end
19
19
 
20
+ def success?
21
+ response.status.error_code.zero?
22
+ end
23
+
20
24
  private
21
25
 
22
26
  def headers
@@ -1,18 +1,20 @@
1
1
  require_relative '../spec_helper'
2
2
 
3
3
  describe FioAPI::Payment do
4
+ let(:date) { '2018-06-15' }
5
+ let(:amount) { 100.0 }
4
6
  before(:each) do
5
- @payment = FioAPI::Payments::Domestic.new(account_from: '11111111', currency: 'CZK', amount: amount, account_to: '22222222', bank_code: '3030', date: '2018-06-15')
7
+ @payment = FioAPI::Payments::Domestic.new(account_from: '11111111', currency: 'CZK', amount: amount, account_to: '22222222', bank_code: '3030', date: date)
6
8
  @service = FioAPI::Payment.new [@payment]
7
9
  end
8
10
 
9
11
  context 'payment with valid data' do
10
- let(:amount) { 100.0 }
11
12
  it 'should make request' do
12
13
  VCR.use_cassette 'import', erb: true do
13
14
  expect(@service.import).to be_a HTTParty::Response
14
15
  expect(@service.request).to be_a HTTParty::Response
15
16
  expect(@service.response).to be_a FioAPI::ImportResponseDeserializer
17
+ expect(@service.success?).to eq true
16
18
  end
17
19
  end
18
20
 
@@ -21,13 +23,46 @@ describe FioAPI::Payment do
21
23
  end
22
24
  end
23
25
 
24
- context 'payment with invalid data' do
26
+ context 'payment with old payment' do
27
+ let(:date) { '2018-05-05' }
28
+ it 'should make request' do
29
+ VCR.use_cassette 'old_import', erb: true do
30
+ expect(@service.import).to be_a HTTParty::Response
31
+ expect(@service.request).to be_a HTTParty::Response
32
+ expect(@service.response).to be_a FioAPI::ImportResponseDeserializer
33
+ expect(@service.success?).to eq false
34
+ end
35
+ end
36
+
37
+ it 'should build path' do
38
+ expect(@service.path).to eq "/import/?token=#{FioAPI.token}&type=xml"
39
+ end
40
+ end
41
+
42
+ context 'payment with wrong token' do
43
+ let(:date) { '2018-05-05' }
44
+ it 'should make request' do
45
+ VCR.use_cassette 'wrong_token_import', erb: true do
46
+ expect(@service.import).to be_a HTTParty::Response
47
+ expect(@service.request).to be_a HTTParty::Response
48
+ expect(@service.response).to be_a FioAPI::ImportResponseDeserializer
49
+ expect(@service.success?).to eq false
50
+ end
51
+ end
52
+
53
+ it 'should build path' do
54
+ expect(@service.path).to eq "/import/?token=#{FioAPI.token}&type=xml"
55
+ end
56
+ end
57
+
58
+ context 'payment with zero amount data' do
25
59
  let(:amount) { '' }
26
60
  it 'should make request' do
27
61
  VCR.use_cassette 'invalid_import', erb: true do
28
62
  expect(@service.import).to be_a HTTParty::Response
29
63
  expect(@service.request).to be_a HTTParty::Response
30
64
  expect(@service.response).to be_a FioAPI::ImportResponseDeserializer
65
+ expect(@service.success?).to eq false
31
66
  end
32
67
  end
33
68
 
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.fio.cz/ib_api/rest/import/?token=<%= FioAPI.token %>&type=xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: "--------------------------YU5IeT1XYDoNHP6A\r\nContent-Disposition:
9
+ form-data; name=\"file\"; filename=\"fio20180606-86151-1fg6aja\"\r\nContent-Type:
10
+ application/octet-stream\r\n\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Import
11
+ xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.fio.cz/schema/importIB.xsd\">\n
12
+ \ <Orders>\n <DomesticTransaction>\n <accountFrom>11111111</accountFrom>\n
13
+ \ <currency>CZK</currency>\n <amount>100.0</amount>\n <accountTo>22222222</accountTo>\n
14
+ \ <bankCode>3030</bankCode>\n <ks/>\n <vs/>\n <ss/>\n <date>2018-05-05</date>\n
15
+ \ <messageForRecipient/>\n <comment/>\n <paymentType>431001</paymentType>\n
16
+ \ </DomesticTransaction>\n </Orders>\n</Import>\n\r\n--------------------------YU5IeT1XYDoNHP6A--\r\n"
17
+ headers:
18
+ Content-Type:
19
+ - multipart/form-data; boundary=------------------------YU5IeT1XYDoNHP6A
20
+ Boundary:
21
+ - "-----------RubyMultipartPost"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Date:
28
+ - Wed, 06 Jun 2018 11:14:56 GMT
29
+ Server:
30
+ - Apache-Coyote/1.1
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ Referrer-Policy:
36
+ - strict-origin-when-cross-origin
37
+ Content-Type:
38
+ - application/xml;charset=UTF-8
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ Strict-Transport-Security:
42
+ - max-age=31536000
43
+ Transfer-Encoding:
44
+ - chunked
45
+ body:
46
+ encoding: ASCII-8BIT
47
+ string: !binary |-
48
+ PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxyZXNwb25zZUltcG9ydCB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4c2k6bm9OYW1lc3BhY2VTY2hlbWFMb2NhdGlvbj0iaHR0cDovL3d3dy5maW8uY3ovc2NoZW1hL3Jlc3BvbnNlSW1wb3J0LnhzZCI+PHJlc3VsdD48ZXJyb3JDb2RlPjE8L2Vycm9yQ29kZT48c3RhdHVzPmVycm9yPC9zdGF0dXM+PHN1bXM+PHN1bSBpZD0iQ1pLIj48c3VtQ3JlZGl0PjA8L3N1bUNyZWRpdD48c3VtRGViZXQ+MTAwLjA8L3N1bURlYmV0Pjwvc3VtPjwvc3Vtcz48L3Jlc3VsdD48b3JkZXJzRGV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YWlsPjwvb3JkZXJzRGV0YWlscz48L3Jlc3BvbnNlSW1wb3J0Pg==
49
+ http_version:
50
+ recorded_at: Wed, 06 Jun 2018 11:14:56 GMT
51
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.fio.cz/ib_api/rest/import/?token=somelongtoken&type=xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: "--------------------------UFUFp-y_DGK55ls6\r\nContent-Disposition:
9
+ form-data; name=\"file\"; filename=\"fio20180606-86327-8ctjzc\"\r\nContent-Type:
10
+ application/octet-stream\r\n\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Import
11
+ xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.fio.cz/schema/importIB.xsd\">\n
12
+ \ <Orders>\n <DomesticTransaction>\n <accountFrom>11111111</accountFrom>\n
13
+ \ <currency>CZK</currency>\n <amount>100.0</amount>\n <accountTo>22222222</accountTo>\n
14
+ \ <bankCode>3030</bankCode>\n <ks/>\n <vs/>\n <ss/>\n <date>2018-05-05</date>\n
15
+ \ <messageForRecipient/>\n <comment/>\n <paymentType>431001</paymentType>\n
16
+ \ </DomesticTransaction>\n </Orders>\n</Import>\n\r\n--------------------------UFUFp-y_DGK55ls6--\r\n"
17
+ headers:
18
+ Content-Type:
19
+ - multipart/form-data; boundary=------------------------UFUFp-y_DGK55ls6
20
+ Boundary:
21
+ - "-----------RubyMultipartPost"
22
+ response:
23
+ status:
24
+ code: 500
25
+ message: Internal Server Error
26
+ headers:
27
+ Date:
28
+ - Wed, 06 Jun 2018 11:16:43 GMT
29
+ Server:
30
+ - Apache-Coyote/1.1
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ Referrer-Policy:
36
+ - strict-origin-when-cross-origin
37
+ Content-Type:
38
+ - text/plain;charset=UTF-8
39
+ Content-Length:
40
+ - '1'
41
+ X-Frame-Options:
42
+ - SAMEORIGIN
43
+ Strict-Transport-Security:
44
+ - max-age=31536000
45
+ Connection:
46
+ - close
47
+ body:
48
+ encoding: UTF-8
49
+ string: " "
50
+ http_version:
51
+ recorded_at: Wed, 06 Jun 2018 11:16:43 GMT
52
+ recorded_with: VCR 4.0.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fio_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Bortlik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-06-04 00:00:00.000000000 Z
12
+ date: 2018-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -170,8 +170,10 @@ files:
170
170
  - spec/fixtures/vcr_cassettes/from_last_fetch.yml
171
171
  - spec/fixtures/vcr_cassettes/import.yml
172
172
  - spec/fixtures/vcr_cassettes/invalid_import.yml
173
+ - spec/fixtures/vcr_cassettes/old_import.yml
173
174
  - spec/fixtures/vcr_cassettes/set_last_fetch_date.yml
174
175
  - spec/fixtures/vcr_cassettes/set_last_fetch_id.yml
176
+ - spec/fixtures/vcr_cassettes/wrong_token_import.yml
175
177
  - spec/spec_helper.rb
176
178
  - spec/utils/hash_spec.rb
177
179
  homepage: http://github.com/14113/fio_api