discountnetwork 0.1.2 → 0.1.3

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: e174ad9cc85380841cbecb16cfbaa6ae642580d3
4
- data.tar.gz: 79bffd2a17871d804db24b82d3789c589ddef1e8
3
+ metadata.gz: 67769839fd2e1a2bc644ac1ee14347e49245a3e4
4
+ data.tar.gz: 2e518bbccb41f513fcb6882fa44336979831c9b1
5
5
  SHA512:
6
- metadata.gz: 97d36b9148cbe85f6aeeeb389f172364ea26e8590ee2588a37e726c6e70299fc419b6112d302eb25ce2d9ffb3cfde0a8ba43be0a6557bfc28cfe2d861c72cdf1
7
- data.tar.gz: 9b5a025a235808c2df27d6038a95eac95ac93d7d2b81ed52f45d969045b56fb8caf918290c50a4f1183f8808c0f327ed697ace32ce82e44786b1ce5dfc619fa3
6
+ metadata.gz: 491ab04c003a4c12241b31f9b432318bfa36d4302371b5179abc5ec3ce112ae0037042de6bae647f064a1ff749f69569a2fed28858f995974800790d6ba6efe2
7
+ data.tar.gz: a1c76ef3c1468ccfc487e0369e006a5170b4263f4df255e50f6ec59cbcf1305c08dafd2c9ed905e48978984fffbf283245380aaea01f52544ba2e143fdb756bd
@@ -2,7 +2,7 @@ AllCops:
2
2
  Exclude:
3
3
  - db/schema.rb
4
4
 
5
- Style/AccessorMethodName:
5
+ Naming/AccessorMethodName:
6
6
  Description: Check the naming of accessor methods for get_/set_.
7
7
  Enabled: false
8
8
 
@@ -21,7 +21,7 @@ Style/AsciiComments:
21
21
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
22
22
  Enabled: false
23
23
 
24
- Style/AsciiIdentifiers:
24
+ Naming/AsciiIdentifiers:
25
25
  Description: 'Use only ascii symbols in identifiers.'
26
26
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers'
27
27
  Enabled: false
@@ -90,6 +90,13 @@ Metrics/AbcSize:
90
90
  branches, and conditions.
91
91
  Enabled: false
92
92
 
93
+ Metrics/BlockLength:
94
+ CountComments: true # count full line comments?
95
+ Max: 25
96
+ ExcludedMethods: []
97
+ Exclude:
98
+ - "spec/**/*"
99
+
93
100
  Metrics/CyclomaticComplexity:
94
101
  Description: >-
95
102
  A complexity metric that is strongly correlated to the number
@@ -100,20 +107,15 @@ Rails/Delegate:
100
107
  Description: 'Prefer delegate method for delegations.'
101
108
  Enabled: false
102
109
 
103
- Style/DeprecatedHashMethods:
104
- Description: 'Checks for use of deprecated Hash methods.'
105
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key'
110
+ Style/PreferredHashMethods:
111
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
112
+ StyleGuide: '#hash-key'
106
113
  Enabled: false
107
114
 
108
115
  Style/Documentation:
109
116
  Description: 'Document classes and non-namespace modules.'
110
117
  Enabled: false
111
118
 
112
- Style/DotPosition:
113
- Description: 'Checks the position of the dot in multi-line method calls.'
114
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
115
- EnforcedStyle: trailing
116
-
117
119
  Style/DoubleNegation:
118
120
  Description: 'Checks for uses of double negation (!!).'
119
121
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
@@ -139,15 +141,17 @@ Style/EvenOdd:
139
141
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
140
142
  Enabled: false
141
143
 
142
- Style/ExtraSpacing:
143
- Description: 'Do not use unnecessary spacing.'
144
- Enabled: true
145
-
146
- Style/FileName:
144
+ Naming/FileName:
147
145
  Description: 'Use snake_case for source file names.'
148
146
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
149
147
  Enabled: false
150
148
 
149
+ Style/FrozenStringLiteralComment:
150
+ Description: >-
151
+ Add the frozen_string_literal comment to the top of files
152
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
153
+ Enabled: false
154
+
151
155
  Style/FlipFlop:
152
156
  Description: 'Checks for flip flops'
153
157
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
@@ -216,25 +220,11 @@ Style/ModuleFunction:
216
220
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
217
221
  Enabled: false
218
222
 
219
- Style/MultilineOperationIndentation:
220
- Description: >-
221
- Checks indentation of binary operations that span more than
222
- one line.
223
- Enabled: true
224
- EnforcedStyle: indented
225
-
226
223
  Style/MultilineBlockChain:
227
224
  Description: 'Avoid multi-line chains of blocks.'
228
225
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
229
226
  Enabled: false
230
227
 
231
- Style/MultilineMethodCallIndentation:
232
- Description: >-
233
- Checks indentation of method calls with the dot operator
234
- that span more than one line.
235
- Enabled: true
236
- EnforcedStyle: indented
237
-
238
228
  Style/NegatedIf:
239
229
  Description: >-
240
230
  Favor unless over if for negative conditions
@@ -276,7 +266,7 @@ Style/OneLineConditional:
276
266
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
277
267
  Enabled: false
278
268
 
279
- Style/OpMethod:
269
+ Naming/BinaryOperatorParameterName:
280
270
  Description: 'When defining binary operators, name the argument other.'
281
271
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
282
272
  Enabled: false
@@ -296,7 +286,7 @@ Style/PerlBackrefs:
296
286
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
297
287
  Enabled: false
298
288
 
299
- Style/PredicateName:
289
+ Naming/PredicateName:
300
290
  Description: 'Check the names of predicate methods.'
301
291
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
302
292
  NamePrefixBlacklist:
@@ -352,24 +342,31 @@ Style/StringLiterals:
352
342
  EnforcedStyle: double_quotes
353
343
  Enabled: true
354
344
 
355
- Style/FrozenStringLiteralComment:
356
- Enabled: false
357
-
358
345
  Style/TrailingCommaInArguments:
359
346
  Description: 'Checks for trailing comma in argument lists.'
360
347
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
361
348
  EnforcedStyleForMultiline: comma
362
- SupportedStyles:
349
+ SupportedStylesForMultiline:
350
+ - comma
351
+ - consistent_comma
352
+ - no_comma
353
+ Enabled: true
354
+
355
+ Style/TrailingCommaInArrayLiteral:
356
+ Description: 'Checks for trailing comma in array literals.'
357
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
358
+ EnforcedStyleForMultiline: comma
359
+ SupportedStylesForMultiline:
363
360
  - comma
364
361
  - consistent_comma
365
362
  - no_comma
366
363
  Enabled: true
367
364
 
368
- Style/TrailingCommaInLiteral:
369
- Description: 'Checks for trailing comma in array and hash literals.'
365
+ Style/TrailingCommaInHashLiteral:
366
+ Description: 'Checks for trailing comma in hash literals.'
370
367
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
371
368
  EnforcedStyleForMultiline: comma
372
- SupportedStyles:
369
+ SupportedStylesForMultiline:
373
370
  - comma
374
371
  - consistent_comma
375
372
  - no_comma
@@ -404,6 +401,48 @@ Style/WordArray:
404
401
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
405
402
  Enabled: false
406
403
 
404
+ # Layout
405
+
406
+ Layout/AlignParameters:
407
+ Description: 'Here we check if the parameters on a multi-line method call or definition are aligned.'
408
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
409
+ Enabled: false
410
+
411
+ Layout/ConditionPosition:
412
+ Description: >-
413
+ Checks for condition placed in a confusing position relative to
414
+ the keyword.
415
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
416
+ Enabled: false
417
+
418
+ Layout/DotPosition:
419
+ Description: 'Checks the position of the dot in multi-line method calls.'
420
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
421
+ EnforcedStyle: trailing
422
+
423
+ Layout/ExtraSpacing:
424
+ Description: 'Do not use unnecessary spacing.'
425
+ Enabled: true
426
+
427
+ Layout/MultilineOperationIndentation:
428
+ Description: >-
429
+ Checks indentation of binary operations that span more than
430
+ one line.
431
+ Enabled: true
432
+ EnforcedStyle: indented
433
+
434
+ Layout/MultilineMethodCallIndentation:
435
+ Description: >-
436
+ Checks indentation of method calls with the dot operator
437
+ that span more than one line.
438
+ Enabled: true
439
+ EnforcedStyle: indented
440
+
441
+ Layout/InitialIndentation:
442
+ Description: >-
443
+ Checks the indentation of the first non-blank non-comment line in a file.
444
+ Enabled: false
445
+
407
446
  # Lint
408
447
 
409
448
  Lint/AmbiguousOperator:
@@ -428,13 +467,6 @@ Lint/CircularArgumentReference:
428
467
  Description: "Don't refer to the keyword argument in the default value."
429
468
  Enabled: false
430
469
 
431
- Lint/ConditionPosition:
432
- Description: >-
433
- Checks for condition placed in a confusing position relative to
434
- the keyword.
435
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
436
- Enabled: false
437
-
438
470
  Lint/DeprecatedClassMethods:
439
471
  Description: 'Check for deprecated class method calls.'
440
472
  Enabled: false
@@ -460,18 +492,7 @@ Lint/HandleExceptions:
460
492
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
461
493
  Enabled: false
462
494
 
463
- Lint/InvalidCharacterLiteral:
464
- Description: >-
465
- Checks for invalid character literals with a non-escaped
466
- whitespace character.
467
- Enabled: false
468
-
469
- Style/InitialIndentation:
470
- Description: >-
471
- Checks the indentation of the first non-blank non-comment line in a file.
472
- Enabled: false
473
-
474
- Lint/LiteralInCondition:
495
+ Lint/LiteralAsCondition:
475
496
  Description: 'Checks of literals used in conditions.'
476
497
  Enabled: false
477
498
 
@@ -512,7 +533,7 @@ Lint/UnderscorePrefixedVariableName:
512
533
  Description: 'Do not use prefix `_` for a variable that is used.'
513
534
  Enabled: false
514
535
 
515
- Lint/UnneededDisable:
536
+ Lint/UnneededCopDisableDirective:
516
537
  Description: >-
517
538
  Checks for rubocop:disable comments that can be removed.
518
539
  Note: this cop is not disabled when disabling all cops.
data/README.md CHANGED
@@ -71,6 +71,17 @@ To retrieve the user account details using the Discount Network `account` API
71
71
  DiscountNetwork::Account.find(auth_token)
72
72
  ```
73
73
 
74
+ #### Create a user account
75
+
76
+ To create a new user account you can use the `Account.create` interface, but one
77
+ important things to remember that account creation is not available for all white
78
+ label, so if it's failing then most likely this feature is not supported on your
79
+ white label.
80
+
81
+ ```ruby
82
+ DiscountNetwork::Account.create(subscriber_attributes)
83
+ ```
84
+
74
85
  #### Update user account
75
86
 
76
87
  Once the user is logged in and `auth_token` has been configured properly then
@@ -7,6 +7,10 @@ module DiscountNetwork
7
7
  end
8
8
  end
9
9
 
10
+ def create(attributes)
11
+ DiscountNetwork.post_resource("account", subscriber: attributes)
12
+ end
13
+
10
14
  def update(attributes)
11
15
  if auth_token_exists?
12
16
  DiscountNetwork.put_resource("account", subscriber: attributes)
@@ -103,6 +103,15 @@ module DiscountNetworkApi
103
103
  )
104
104
  end
105
105
 
106
+ def stub_account_create_api(attributes)
107
+ stub_api_response(
108
+ :post,
109
+ "account",
110
+ data: { subscriber: attributes },
111
+ filename: "user",
112
+ )
113
+ end
114
+
106
115
  def stub_activation_find_api(token)
107
116
  stub_api_response(
108
117
  :get,
@@ -1,3 +1,3 @@
1
1
  module Discountnetwork
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  end
@@ -16,6 +16,17 @@ describe DiscountNetwork::Account do
16
16
  end
17
17
  end
18
18
 
19
+ describe ".create" do
20
+ it "creates and returns created user" do
21
+ stub_account_create_api(user_attributes)
22
+
23
+ response = DiscountNetwork::Account.create(user_attributes)
24
+
25
+ expect(response.user.name).not_to be_nil
26
+ expect(response.user.status).to eq("Active")
27
+ end
28
+ end
29
+
19
30
  describe ".update" do
20
31
  it "updates the subscriber account" do
21
32
  auth_token = "ABCD_123"
@@ -33,4 +44,23 @@ describe DiscountNetwork::Account do
33
44
  def set_account_auth_token(token)
34
45
  DiscountNetwork.configuration.auth_token = token
35
46
  end
47
+
48
+ def user_attributes
49
+ @user_attributes ||= {
50
+ first_name: "John",
51
+ last_name: "Doe",
52
+ sex: "Male",
53
+ address: "123 Main Street",
54
+ city: "New York",
55
+ zip: "NY123",
56
+ state: "New York",
57
+ phone: "+1 123 456 789 0123",
58
+ mobile: "+1 012 345 678 9012",
59
+ username: "john.doe",
60
+ email: "john.doe@example.com",
61
+ country: "US",
62
+ password: "secret_password",
63
+ password_confirmation: "secret_password",
64
+ }
65
+ end
36
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discountnetwork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abu Nashir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-12 00:00:00.000000000 Z
11
+ date: 2018-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client