moss_generator 0.5.2 → 0.6.0

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
  SHA256:
3
- metadata.gz: 7f95b7ed0d7074f3ca87040394af09e0ba85bdd2f68eb70dcec3166027c2b204
4
- data.tar.gz: 8f333d25b73c6c3b03941bd15e7dd0ee8b96d35f0ad7469c99e8ca2512bfa142
3
+ metadata.gz: b22a165ad650e03060e839cd9ea483817eec530a42836fc8f5e9d935aa2cebd5
4
+ data.tar.gz: 3989024f80875480c50112e1360d6100e14d75cfceff9ab99a569a447de1becb
5
5
  SHA512:
6
- metadata.gz: a2d2cdc21fa1fc84da5561cf73b506d79f25c034d3f12d68eea7b4e9bca20fb46a2c7a2709c6d7ad9dce49b717308dabfaf251f7fdb8f6e476750b026ac67eda
7
- data.tar.gz: ba490e2a77965cbf52957977482e85ba6011f2374fa9c223abb8f528311d56a4f677f6b6f6841fa1b2d83978698739d7c787ca072b619af00a324343c0ca3936
6
+ metadata.gz: 45da0e44d80d6f5f04f762c948af8e91127b2deedd6d67ea23b77a8f731797a98e5674272d8084e9bfbff391803d18cefcbe0716ef802d000dc15aac58420416
7
+ data.tar.gz: 3ab6c4be61713bf7032db78373d156c7a397a41d8ee1173097316d059229dfa7133e2416c01b1b60e29ad6fef43545cc3fe218e2553eda2ac42f6173a7da9eae
data/.rubocop.yml CHANGED
@@ -10,6 +10,9 @@ AllCops:
10
10
  Layout/LineLength:
11
11
  Max: 80
12
12
 
13
+ Metrics/ClassLength:
14
+ Max: 120
15
+
13
16
  Metrics/ParameterLists:
14
17
  Max: 6
15
18
 
@@ -18,4 +21,4 @@ Metrics/BlockLength:
18
21
  - 'spec/**/*'
19
22
 
20
23
  RSpec/NestedGroups:
21
- Max: 5
24
+ Max: 6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- moss_generator (0.5.2)
4
+ moss_generator (0.6.0)
5
5
  countries (~> 4.0)
6
6
  money (~> 6.14)
7
7
  valvat (~> 1.1)
@@ -98,7 +98,37 @@ module MossGenerator
98
98
  end
99
99
 
100
100
  def fetch_country_code
101
- charge.dig('payment_method_details', 'card', 'country')
101
+ source_country || payment_method_country || fallback_country
102
+ end
103
+
104
+ def source_country
105
+ return source_owner_country if source_type.nil?
106
+
107
+ charge.dig('source', source_type, 'country') ||
108
+ charge.dig('source', source_type, 'address_country')
109
+ end
110
+
111
+ def payment_method_country
112
+ return if payment_type.nil?
113
+
114
+ charge.dig('payment_method_details', payment_type, 'country') ||
115
+ charge.dig('payment_method_details', payment_type, 'address_country')
116
+ end
117
+
118
+ def source_type
119
+ charge.dig('source', 'type') || charge.dig('source', 'object')
120
+ end
121
+
122
+ def source_owner_country
123
+ charge.dig('source', 'owner', 'address', 'country')
124
+ end
125
+
126
+ def payment_type
127
+ charge.dig('payment_method_details', 'type')
128
+ end
129
+
130
+ def fallback_country
131
+ charge.dig('shipping', 'address', 'country')
102
132
  end
103
133
 
104
134
  def amount_with_vat
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MossGenerator
4
- VERSION = '0.5.2'
4
+ VERSION = '0.6.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moss_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - frdrkolsson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-04 00:00:00.000000000 Z
11
+ date: 2022-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: countries