cognito-client 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -1
  3. data/Gemfile +37 -0
  4. data/Guardfile +4 -0
  5. data/README.md +55 -18
  6. data/Rakefile +3 -5
  7. data/bin/console +1 -1
  8. data/circle.yml +7 -0
  9. data/cognito.gemspec +4 -6
  10. data/config/devtools.yml +2 -0
  11. data/config/errors.yml +2 -0
  12. data/config/flay.yml +5 -0
  13. data/config/flog.yml +5 -0
  14. data/config/mutant.yml +6 -0
  15. data/config/reek.yml +111 -0
  16. data/config/rubocop.yml +91 -0
  17. data/config/yardstick.yml +2 -0
  18. data/lib/cognito/client.rb +59 -96
  19. data/lib/cognito/client/command.rb +34 -0
  20. data/lib/cognito/client/commands/create_identity.rb +22 -0
  21. data/lib/cognito/client/commands/create_identity_assessment.rb +26 -0
  22. data/lib/cognito/client/commands/create_identity_search.rb +37 -0
  23. data/lib/cognito/client/commands/create_profile.rb +24 -0
  24. data/lib/cognito/client/commands/mixins/create_behavior.rb +20 -0
  25. data/lib/cognito/client/commands/retrieve_identity_location.rb +28 -0
  26. data/lib/cognito/client/commands/retrieve_identity_search_job.rb +40 -0
  27. data/lib/cognito/client/connection.rb +36 -0
  28. data/lib/cognito/client/document.rb +32 -0
  29. data/lib/cognito/client/params.rb +13 -0
  30. data/lib/cognito/client/params/identity.rb +48 -0
  31. data/lib/cognito/client/params/identity_assessment.rb +23 -0
  32. data/lib/cognito/client/params/identity_search.rb +25 -0
  33. data/lib/cognito/client/params/omitted.rb +9 -0
  34. data/lib/cognito/client/request.rb +98 -0
  35. data/lib/cognito/client/resource.rb +124 -0
  36. data/lib/cognito/client/resource/identity_assessment.rb +53 -0
  37. data/lib/cognito/client/resource/identity_search.rb +64 -0
  38. data/lib/cognito/client/resource/identity_search_job.rb +12 -0
  39. data/lib/cognito/client/resource/profile.rb +10 -0
  40. data/lib/cognito/client/resource_identifier.rb +17 -0
  41. data/lib/cognito/client/response.rb +17 -0
  42. data/lib/cognito/client/response/builder.rb +48 -0
  43. data/lib/cognito/client/response/identity_assessment.rb +10 -0
  44. data/lib/cognito/client/response/identity_search.rb +32 -0
  45. data/lib/cognito/client/response/identity_search_job.rb +20 -0
  46. data/lib/cognito/client/response/profile.rb +10 -0
  47. data/lib/cognito/version.rb +3 -3
  48. metadata +77 -83
  49. data/.rubocop.yml +0 -57
  50. data/.travis.yml +0 -4
  51. data/lib/cognito.rb +0 -32
  52. data/lib/cognito/cleaner.rb +0 -30
  53. data/lib/cognito/constants.rb +0 -8
  54. data/lib/cognito/document.rb +0 -33
  55. data/lib/cognito/error.rb +0 -8
  56. data/lib/cognito/notary.rb +0 -56
  57. data/lib/cognito/resource.rb +0 -129
  58. data/lib/cognito/resource/identity_assessment.rb +0 -40
  59. data/lib/cognito/resource/identity_search.rb +0 -63
  60. data/lib/cognito/resource/identity_search_job.rb +0 -11
  61. data/lib/cognito/resource/profile.rb +0 -9
  62. data/lib/cognito/responder.rb +0 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f68b740a5ba516167ad1927faf7372906f7a4cd
4
- data.tar.gz: fc8c54beb597ceb364c16d8f4474f917c0ddfad2
3
+ metadata.gz: 86e3186a7250f7e2aece863f01c09823bdff4864
4
+ data.tar.gz: 7d3ac5b3649e5027f309ced4325b132e369b5385
5
5
  SHA512:
6
- metadata.gz: e3bc88bf4ad7896032056f5f6e6c245ef34071953b9e62aa3824dde40e8542e44b904917b3faa4daf1de1f5d8ec9297a8b7bb1af2e076a5cf2e570cf92bdbb81
7
- data.tar.gz: e2906b5cfd7bab859723b88368168b047821da3a8b805c902504ae925d54402028b264247791e962f1c28b4f74cfd97a9411fa7f5ed17d64d5b9357dfa24b5e8
6
+ metadata.gz: f60da529529285bc97b3ead92afbd912a5c82314b2725b914afffb19b5d26769d111c1f20f8b78a00f4cc3dfce01d71898298b51bf58a4615dce2df49f705413
7
+ data.tar.gz: 3c18ced1a8f32d98ab893982135b358851536b3822706bc824370eac98ef30a9ada94bfbaa34c35280b532c415cc19877ee5b7fd91d20e0fbf9d9b3b0a4cbd69
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
- --format documentation
2
1
  --color
2
+ --format documentation
3
+ --require spec_helper
data/Gemfile CHANGED
@@ -3,3 +3,40 @@ source 'https://rubygems.org'
3
3
 
4
4
  # Specify your gem's dependencies in cognito.gemspec
5
5
  gemspec
6
+
7
+ group(:tools) do
8
+ # mutation testing tool for ruby
9
+ gem 'mutant', '~> 0.8.10'
10
+
11
+ # Rspec integration for mutant
12
+ gem 'mutant-rspec', '~> 0.8.8'
13
+
14
+ # Watches file system and invokes commands according to mapping rules
15
+ gem 'guard', '~> 2.14.0'
16
+
17
+ # Plugin to guard for RSpec tooling
18
+ gem 'guard-rspec', '~> 4.7.2'
19
+
20
+ # A metagem wrapping development tools:
21
+ # procto,
22
+ # adamantium,
23
+ # anima,
24
+ # concord,
25
+ # rspec, rspec-core, rspec-its
26
+ # rake,
27
+ # yard,
28
+ # flog,
29
+ # flay,
30
+ # reek,
31
+ # rubocop,
32
+ # simplecov,
33
+ # yardstick,
34
+ # mutant, mutant-rspec
35
+ gem 'devtools', '~> 0.1.8'
36
+
37
+ # Rubocop extensions which reflect BlockScore's style guide
38
+ gem 'rubocop-devtools', git: 'https://github.com/backus/rubocop-devtools.git'
39
+
40
+ # Enforce style and convention for rspec
41
+ gem 'rubocop-rspec', git: 'https://github.com/nevir/rubocop-rspec.git'
42
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ guard :rspec, cmd: 'bundle exec rspec' do
3
+ watch(/.+\.rb$/) { 'spec' }
4
+ end
data/README.md CHANGED
@@ -1,12 +1,6 @@
1
1
  # Cognito Client
2
2
 
3
- Unofficial Ruby client for the BlockScore Cognito API.
4
-
5
- Frankenstein of demo code supplied by BlockScore, and our own stuff. `client.rb` is ours,
6
- everything else is theirs. The BlockScore code basically just handles the structuring
7
- of their data models.
8
-
9
- Currently in the "make it work" phase of development.
3
+ Unofficial Ruby client for the BlockScore Cognito API. This library was designed using a [command-query separation principle](https://en.wikipedia.org/wiki/Command–query_separation).
10
4
 
11
5
  ## Installation
12
6
 
@@ -22,29 +16,72 @@ And then execute:
22
16
 
23
17
  ## Usage
24
18
 
25
- Create a client
19
+ ### Creating a client
20
+
21
+ ```ruby
22
+ client = Cognito::Client.create(
23
+ api_key: 'your-api-key',
24
+ api_secret: 'your-api-secret',
25
+ uri: 'https://sandbox.cognitohq.com',
26
+ api_version: '2016-09-01'
27
+ )
28
+ ```
29
+
30
+ ### Creating a profile
26
31
 
27
32
  ```ruby
28
- client = Cognito::Client.new(api_key: 'API_KEY', api_secret: 'API_SECRET')
33
+ profile = client.create_profile
34
+ ```
35
+
36
+ ### Create an identity search with phone and name
29
37
 
30
- # default base URI is https://sandbox.cognitohq.com
31
- #
32
- # to set a different API:
33
- client.base_uri('SOME_NEW_BASE_URI')
38
+ ```ruby
39
+ search = client.create_identity_search(
40
+ profile_id: profile.data.id,
41
+ phone_number: '+14151231234',
42
+ name: { # optional
43
+ first: 'Leslie',
44
+ last: 'Knope'
45
+ }
46
+ )
34
47
  ```
35
48
 
36
- Create a Profile:
49
+ ### Creating an identity assessment for the search
37
50
 
38
51
  ```ruby
39
- profile = client.create_profile!
52
+ assessment = search.create_assessment(
53
+ phone_number: '+14151231234',
54
+ name: {
55
+ first: 'Leslie',
56
+ last: 'Doe'
57
+ }
58
+ )
40
59
  ```
41
60
 
42
- Initiate a search against a phone number:
61
+ ### Traversing the data
62
+
63
+ The client automatically links the resource relationships allowing you to make calls like:
43
64
 
44
65
  ```ruby
45
- profile = client.create_profile!
66
+ search.data.identity_records.first.names.map(&:attributes)
46
67
 
47
- search = client.search!(profile.id, '+14151231234')
68
+ # [
69
+ # { :first=>"LESLIE", :middle=>"BARBARA", :last=>"KNOPE" },
70
+ # {:first=>"LESLIE", :middle=>nil, :last=>"KNOPE-WYATT" }
71
+ # ]
72
+
73
+ ```
74
+
75
+ ## Running the test suite
76
+
77
+ ```
78
+ bundle exec rspec
79
+ ```
80
+
81
+ ## Running the CI tasks
82
+
83
+ ```
84
+ bundle exec rake ci
48
85
  ```
49
86
 
50
87
  ## License
data/Rakefile CHANGED
@@ -1,7 +1,5 @@
1
+ # encoding: utf-8
1
2
  # frozen_string_literal: true
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
4
3
 
5
- RSpec::Core::RakeTask.new(:spec)
6
-
7
- task default: :spec
4
+ require 'devtools'
5
+ Devtools.init_rake_tasks
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
- require 'cognito'
5
+ require 'cognito/client'
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -0,0 +1,7 @@
1
+ ---
2
+ machine:
3
+ ruby:
4
+ version: '2.3.1'
5
+ test:
6
+ override:
7
+ - bundle exec rake ci
@@ -21,16 +21,14 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency 'bundler', '~> 1.11'
23
23
  spec.add_development_dependency 'pry', '~> 0.10'
24
- spec.add_development_dependency 'rake', '~> 11.2'
25
- spec.add_development_dependency 'rspec', '~> 3.5'
26
- spec.add_development_dependency 'rubocop', '~> 0.41'
27
- spec.add_development_dependency 'timecop', '~> 0.8'
28
- spec.add_development_dependency 'rspec-its', '~> 1.2.0'
29
24
 
30
25
  spec.add_dependency 'abstract_type', '~> 0.0.7'
31
26
  spec.add_dependency 'adamantium', '~> 0.2.0'
32
27
  spec.add_dependency 'anima', '~> 0.3.0'
33
28
  spec.add_dependency 'concord', '~> 0.1.5'
34
- spec.add_dependency 'httparty', '~> 0.13'
35
29
  spec.add_dependency 'procto', '~> 0.0.3'
30
+ spec.add_dependency 'ice_nine', '~> 0.11.2'
31
+
32
+ spec.add_runtime_dependency 'http', '~> 2.0', '>= 2.0.3'
33
+ spec.add_runtime_dependency 'addressable', '~> 2.4', '>= 2.4.0'
36
34
  end
@@ -0,0 +1,2 @@
1
+ ---
2
+ unit_test_timeout: 1.0
@@ -0,0 +1,2 @@
1
+ ---
2
+ :messages: []
@@ -0,0 +1,5 @@
1
+ ---
2
+ threshold: 12
3
+ total_score: 198
4
+ lib_dirs:
5
+ - lib
@@ -0,0 +1,5 @@
1
+ ---
2
+ threshold: 17.8
3
+ lib_dirs:
4
+ - -lib/cog/client/request.rb # Uses squiggly heredoc
5
+ - lib
@@ -0,0 +1,6 @@
1
+ name: cognito/client
2
+ namespace: Cognito
3
+ since: HEAD~1
4
+ ignore_subjects:
5
+ - 'Cognito::Client::Document#resolve'
6
+ expect_coverage: 1/1
@@ -0,0 +1,111 @@
1
+ ---
2
+ Attribute:
3
+ enabled: false
4
+ exclude: []
5
+ BooleanParameter:
6
+ enabled: true
7
+ exclude: []
8
+ ClassVariable:
9
+ enabled: true
10
+ exclude: []
11
+ ControlParameter:
12
+ enabled: true
13
+ exclude: []
14
+ DataClump:
15
+ enabled: true
16
+ exclude: []
17
+ max_copies: 2
18
+ min_clump_size: 2
19
+ DuplicateMethodCall:
20
+ enabled: false
21
+ exclude: []
22
+ max_calls: 1
23
+ allow_calls: []
24
+ FeatureEnvy:
25
+ enabled: true
26
+ exclude: []
27
+ IrresponsibleModule:
28
+ enabled: false
29
+ exclude: []
30
+ LongParameterList:
31
+ enabled: true
32
+ exclude: []
33
+ max_params: 3
34
+ overrides:
35
+ initialize:
36
+ max_params: 5
37
+ LongYieldList:
38
+ enabled: true
39
+ exclude: []
40
+ max_params: 3
41
+ ModuleInitialize:
42
+ enabled: true
43
+ exclude: []
44
+ NestedIterators:
45
+ enabled: true
46
+ exclude: []
47
+ max_allowed_nesting: 2
48
+ ignore_iterators: []
49
+ NilCheck:
50
+ enabled: true
51
+ exclude: []
52
+ PrimaDonnaMethod:
53
+ enabled: true
54
+ exclude: []
55
+ RepeatedConditional:
56
+ enabled: true
57
+ exclude: []
58
+ max_ifs: 2
59
+ TooManyInstanceVariables:
60
+ enabled: true
61
+ exclude: []
62
+ max_instance_variables: 9
63
+ TooManyMethods:
64
+ enabled: true
65
+ exclude: []
66
+ max_methods: 25
67
+ TooManyStatements:
68
+ enabled: true
69
+ exclude:
70
+ - initialize
71
+ max_statements: 5
72
+ UncommunicativeMethodName:
73
+ enabled: true
74
+ exclude: []
75
+ reject:
76
+ - !ruby/regexp /^[a-z]$/
77
+ - !ruby/regexp /[0-9]$/
78
+ - !ruby/regexp /[A-Z]/
79
+ accept: []
80
+ UncommunicativeModuleName:
81
+ enabled: true
82
+ exclude: []
83
+ reject:
84
+ - !ruby/regexp /^.$/
85
+ - !ruby/regexp /[0-9]$/
86
+ accept:
87
+ - Inline::C
88
+ UncommunicativeParameterName:
89
+ enabled: true
90
+ exclude: []
91
+ reject:
92
+ - !ruby/regexp /^.$/
93
+ - !ruby/regexp /[0-9]$/
94
+ - !ruby/regexp /[A-Z]/
95
+ - !ruby/regexp /^_/
96
+ accept: []
97
+ UncommunicativeVariableName:
98
+ enabled: true
99
+ exclude: []
100
+ reject:
101
+ - !ruby/regexp /^.$/
102
+ - !ruby/regexp /[0-9]$/
103
+ - !ruby/regexp /[A-Z]/
104
+ accept:
105
+ - _
106
+ UnusedParameters:
107
+ enabled: true
108
+ exclude: []
109
+ UtilityFunction:
110
+ enabled: true
111
+ exclude: []
@@ -0,0 +1,91 @@
1
+ ---
2
+ require:
3
+ - rubocop-rspec
4
+ - rubocop/devtools
5
+ inherit_gem:
6
+ rubocop-devtools: config/default.yml
7
+ AllCops:
8
+ Exclude:
9
+ - vendor/**/*
10
+ - db/migrate/*
11
+ DisplayCopNames: true
12
+ TargetRubyVersion: 2.3
13
+ # This ends up being too spammy
14
+ Style/Documentation:
15
+ Enabled: false
16
+ Style/ExtraSpacing:
17
+ AllowForAlignment: true
18
+ Metrics/LineLength:
19
+ Max: 100
20
+ Style/IfUnlessModifier:
21
+ MaxLineLength: 100
22
+ Style/Next:
23
+ EnforcedStyle: always
24
+ Style/PercentLiteralDelimiters:
25
+ PreferredDelimiters:
26
+ '%i': '[]'
27
+ '%I': '[]'
28
+ '%q': '{}'
29
+ '%Q': '{}'
30
+ '%r': '{}'
31
+ '%s': ()
32
+ '%w': '[]'
33
+ '%W': '[]'
34
+ '%x': ()
35
+ Style/TrivialAccessors:
36
+ ExactNameMatch: false
37
+ Style/MethodCalledOnDoEndBlock:
38
+ Enabled: true
39
+ Style/SymbolArray:
40
+ Enabled: true
41
+ Style/BarePercentLiterals:
42
+ EnforcedStyle: percent_q
43
+ Style/CollectionMethods:
44
+ Enabled: true
45
+ Style/Send:
46
+ Enabled: true
47
+ Style/AutoResourceCleanup:
48
+ Enabled: true
49
+ Style/FirstArrayElementLineBreak:
50
+ Enabled: true
51
+ Style/FirstHashElementLineBreak:
52
+ Enabled: true
53
+ Style/FirstMethodArgumentLineBreak:
54
+ Enabled: true
55
+ Style/FirstMethodParameterLineBreak:
56
+ Enabled: true
57
+ Style/MultilineArrayBraceLayout:
58
+ Enabled: true
59
+ Style/MultilineAssignmentLayout:
60
+ EnforcedStyle: new_line
61
+ Enabled: true
62
+ Style/MultilineHashBraceLayout:
63
+ Enabled: true
64
+ Style/MultilineMethodCallBraceLayout:
65
+ Enabled: true
66
+ Style/MultilineMethodDefinitionBraceLayout:
67
+ Enabled: true
68
+ Style/OptionHash:
69
+ Enabled: true
70
+ Style/StringMethods:
71
+ Enabled: true
72
+ Style/IndentArray:
73
+ EnforcedStyle: consistent
74
+ Style/IndentHash:
75
+ EnforcedStyle: consistent
76
+ MultilineMethodCallIndentation:
77
+ EnforcedStyle: indented
78
+ Style/Alias:
79
+ EnforcedStyle: prefer_alias_method
80
+ Style/AlignHash:
81
+ EnforcedColonStyle: table
82
+ Style/SignalException:
83
+ EnforcedStyle: semantic
84
+ Style/SingleLineBlockParams:
85
+ Enabled: false
86
+ RSpec/DescribeClass:
87
+ Exclude: []
88
+ RSpec/ExampleLength:
89
+ Enabled: false
90
+ RSpec/VerifiedDoubles:
91
+ IgnoreSymbolicNames: true