monobank 0.3.0 → 1.0.0

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: 1330fb91b27e94addd547a3e917a377569f7f94da100c549608c482fad521a31
4
+ data.tar.gz: 4fa1fcb966b87ad1ae081ac1d0dbc011c3bec0b3ffc40a969040c27b41ab1afd
5
5
  SHA512:
6
- metadata.gz: 7cdfec02d3d6c96ca18565af5db3e779b479b77722db0d170f3aa7ff144c4229112a57736809faec916010d96c474072911fbc7e1790299a52c4db50b6e40e90
7
- data.tar.gz: c9cf70b27da7289cec013e577fe194feebfea8d9c05b09e2a690feba1036a04d582631cc774643cc32069f90347008db3311d3895bfbd16d74c6739e0d11c844
6
+ metadata.gz: d7aba78c72f755a0cc634914f9be012c7e12c1a739e3ed54c1d186328476c263c9dfdcfa058134819fb066ce1088e636805fd85555ade32ee05c6067eeb23273
7
+ data.tar.gz: 0ef715b877691c7669efc5dc64b7b428fd761b365f060426fc68e3ed31daa852c4a03b37fb8f59147162672a945f40081e2c0a2183cf5d4767cffd075cab226d
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Monobank
2
- VERSION = "0.3.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -72,6 +72,14 @@ 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.currency_code).to eq 980
76
+ expect(result.attributes).to match hash_including(
77
+ 'accounts' => array_including([
78
+ hash_including(
79
+ "currency_code" => 980
80
+ )
81
+ ])
82
+ )
75
83
  end
76
84
  end
77
85
 
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.0
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-02 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.