monobank 0.3.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: 15be031b6729c65effbd0495c54824eea911e9162101b373f0b3cf35b598f851
4
- data.tar.gz: e4c51fd2a95aab6bbe4313be5e5f65c6c45f0a0f8eb67a527d7e530519a10ded
3
+ metadata.gz: fa6a4b4a03f093b373724d73bbbda12ffd6c1d1728f40b5284090d9f7d1cc4fa
4
+ data.tar.gz: 6ee7b8871210e0651a7d12c93444a369b2b8601b8e1e156039d52eedf97b3626
5
5
  SHA512:
6
- metadata.gz: 7cdfec02d3d6c96ca18565af5db3e779b479b77722db0d170f3aa7ff144c4229112a57736809faec916010d96c474072911fbc7e1790299a52c4db50b6e40e90
7
- data.tar.gz: c9cf70b27da7289cec013e577fe194feebfea8d9c05b09e2a690feba1036a04d582631cc774643cc32069f90347008db3311d3895bfbd16d74c6739e0d11c844
6
+ metadata.gz: ba86f1e0bc80f16805392f7aa1fe8612b4e50d3ea41b5f348111f1d585444e747e9bb90d2bb934bff874aa8ddcda10c98596757f34d1ae7a911d00b427f0bded
7
+ data.tar.gz: 66a504cfe64367f7f2c85b22da02e6f64927f6f4d324397608b6329e72ebd80ed2de1eb0bb9e8c60962e6a05a5dc17814382f8973dd0afb88832db29932b3207
@@ -8,10 +8,11 @@ module Monobank
8
8
  end
9
9
 
10
10
  def call
11
- attributes = response
12
- return define_resources(attributes) if attributes.code == 200
11
+ http_response = response
12
+ attributes = http_response.parsed_response
13
+ return define_resources(attributes) if http_response.code == 200
13
14
 
14
- Monobank::Resources::Error.new(attributes.merge('code' => attributes.code))
15
+ Monobank::Resources::Error.new(attributes.merge('code' => http_response.code))
15
16
  end
16
17
 
17
18
  private
@@ -8,27 +8,24 @@ module Monobank
8
8
  end
9
9
 
10
10
  def initialize(attributes)
11
- @attributes = {}
12
- snake_case_attributes = deep_snake_case(attributes)
13
- snake_case_attributes.each { |key, value| @attributes[method_name(key)] = value }
11
+ @attributes = deep_snake_case(attributes)
14
12
  end
15
13
 
16
14
  def method_name(key)
17
15
  key.gsub(/(.)([A-Z])/,'\1_\2').downcase
18
16
  end
19
17
 
20
- def deep_snake_case(hash)
21
- return hash unless hash.is_a?(Array) || hash.is_a?(Hash)
22
-
23
- hash.each_with_object({}) do |(key, value), object|
24
- object[method_name(key)] =
25
- if value.is_a? Hash
26
- deep_snake_case(value)
27
- elsif value.is_a? Array
28
- value.map { |element| deep_snake_case(element) }
29
- else
30
- value
31
- end
18
+ def deep_snake_case(object)
19
+ if object.is_a?(Hash)
20
+ object.map do |key, value|
21
+ [method_name(key), deep_snake_case(value)]
22
+ end.to_h
23
+ elsif object.is_a?(Array)
24
+ object.map do |value|
25
+ deep_snake_case(value)
26
+ end
27
+ else
28
+ object
32
29
  end
33
30
  end
34
31
 
@@ -4,7 +4,7 @@ module Monobank
4
4
  module Resources
5
5
  module Personal
6
6
  class Accounts < Base
7
- define_fields %w[id balance credit_limit currency_code cashback_type]
7
+ define_fields %w[id type balance credit_limit currency_code cashback_type]
8
8
  end
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Monobank
2
- VERSION = "0.3.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -72,6 +72,15 @@ describe Monobank do
72
72
  result = Monobank.client_info(token:)
73
73
  expect(result.name).to eq 'Мазепа Іван'
74
74
  expect(result.accounts.length).to eq 1
75
+ expect(result.accounts.first.type).to eq 'black'
76
+ expect(result.accounts.first.currency_code).to eq 980
77
+ expect(result.attributes).to match hash_including(
78
+ 'accounts' => array_including([
79
+ hash_including(
80
+ "currency_code" => 980
81
+ )
82
+ ])
83
+ )
75
84
  end
76
85
  end
77
86
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monobank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - vergilet
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-02-23 00:00:00.000000000 Z
13
+ date: 2024-05-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.4.21
156
+ rubygems_version: 3.5.6
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Unofficial Ruby Gem for Monobank API.