reach5 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d219d584e8557fb2b2969e16da8c8b6001387c2
4
+ data.tar.gz: e1050873cd63c0f42f414cc2687b71e04d7b71ab
5
+ SHA512:
6
+ metadata.gz: a41bf94fa99820912a93d7a3a67ebee423666230a519f5abf429522eb2e35d005c711482ccb2f777531dfb90b614a03f3cd6b0921af3b5d231e6a71307f86ed0
7
+ data.tar.gz: eaf632dc98b20e78a4e44222ba18a8a001f9ed54565cc69eea9b3811c814d767222835b961f1d6730c9c92f5106cc5c0f194603b11ff80d40b3d6e690e54d4eb
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /.bundle/
2
+ /Gemfile.lock
3
+ /pkg/
4
+
5
+ # Store configuration for bin/console
6
+ /console.rb
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/AccessorMethodName:
8
+ Exclude:
9
+ - lib/reach5/api.rb
10
+
11
+ Style/TrailingCommaInLiteral:
12
+ EnforcedStyleForMultiline: consistent_comma
13
+
14
+ Style/AsciiComments:
15
+ Enabled: false
16
+
17
+ Style/BlockDelimiters:
18
+ EnforcedStyle: semantic
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ v0.1.0 - 2017-01-30
2
+ ===================
3
+
4
+ First release.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Sunny Ripert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # Reach5
2
+
3
+ Ruby Gem to integrate to the Reach5 Customer Identity Management Platform.
4
+
5
+
6
+ ## Usage
7
+
8
+ ```rb
9
+ Reach5::API.new.post_login(
10
+ provider: "facebook",
11
+ provider_token: "f00b4r",
12
+ user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) …",
13
+ )
14
+ ```
15
+
16
+ ## Installation
17
+
18
+ Add these lines to your application's Gemfile:
19
+
20
+ ```rb
21
+ # Reach5 Customer Identity Management Platform API
22
+ gem "reach5", git: "https://github.com/sunny/reach5"
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+
30
+ ## Configuration
31
+
32
+ ```rb
33
+ Reach5.configure do |c|
34
+ c.customer_domain = "YOUR_CUSTOMER_DOMAIN"
35
+ c.client_key = "YOUR_CLIENT_KEY"
36
+ c.client_secret = "YOUR_SECRET_ACCESS_TOKEN"
37
+ end
38
+ ```
39
+
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies.
44
+ Then, run `rake` to run the specs and style checker.
45
+
46
+ You can also run `bin/console` for an interactive prompt that will allow you
47
+ to experiment. You can place your configuration in the untracked `./console.rb`
48
+ file to have it loaded whenever you load the console.
49
+
50
+ To release a new version, update the version number in `version.rb`, update the
51
+ `CHANGELOG.md` and then run `bundle exec rake release`, which will create a git
52
+ tag for the version, push git commits and tags, and push the `.gem` file
53
+ to [rubygems.org](https://rubygems.org).
54
+
55
+
56
+ ## Contributing
57
+
58
+ Bug reports and pull requests are welcome on GitHub at
59
+ https://github.com/sunny/reach5. This project is intended to be a safe,
60
+ welcoming space for collaboration, and contributors are expected to adhere to
61
+ the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
62
+
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the
67
+ [MIT License](http://opensource.org/licenses/MIT).
68
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # Bundler
2
+ require "bundler/gem_tasks"
3
+
4
+ # Rspec
5
+ require "rspec/core/rake_task"
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ # Rubocop
9
+ require "rubocop/rake_task"
10
+ RuboCop::RakeTask.new(:rubocop)
11
+
12
+ task default: [:spec, :rubocop]
data/bin/console ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "reach5"
5
+
6
+ if File.exist?("./console.rb")
7
+ load "./console.rb"
8
+ else
9
+ Reach5.configure do end
10
+ end
11
+
12
+ require "irb"
13
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
data/lib/reach5/api.rb ADDED
@@ -0,0 +1,77 @@
1
+ module Reach5
2
+ # Handles all calls to Reach5's API.
3
+ class API
4
+ # Get a new access token.
5
+ #
6
+ # Example:
7
+ # Reach5::API.new.get_access_token
8
+ # # => {
9
+ # # "auth" => {
10
+ # # "accessToken" => "f00b4r",
11
+ # # "expires" => 43200
12
+ # # },
13
+ # # "status" => "success",
14
+ # # }
15
+ def get_access_token
16
+ params = {
17
+ client_key: Reach5.configuration.client_key,
18
+ client_secret: Reach5.configuration.client_secret,
19
+ }
20
+ request = HTTP.get("#{host}/api/v1/access_token", params: params)
21
+ request.parse
22
+ end
23
+
24
+ # Collects and stores profile data from an Auth provider.
25
+ #
26
+ # Example:
27
+ # Reach5::API.new.post_login(provider: 'facebook',
28
+ # provider_token: 'f00b4r')
29
+ # # => {
30
+ # # "profile" => {
31
+ # # …
32
+ # # },
33
+ # # "status" => "success",
34
+ # # }
35
+ def post_login(provider:,
36
+ provider_token:,
37
+ provider_secret: nil,
38
+ user_agent: nil)
39
+ params = {
40
+ provider: provider,
41
+ provider_token: provider_token,
42
+ provider_secret: provider_secret,
43
+ user_agent: user_agent,
44
+ }
45
+ HTTP.post("#{host}/api/v1/login", params: params).parse
46
+ end
47
+
48
+ # List profiles
49
+ #
50
+ # Example:
51
+ # Reach5::API.new.get_profiles
52
+ #
53
+ # # => {
54
+ # # "total" => 42,
55
+ # # "items" => […],
56
+ # # "status" => "success",
57
+ # # }
58
+ def get_profiles(page: 1, count: 10)
59
+ params = {
60
+ access_token: access_token,
61
+ page: page,
62
+ count: count,
63
+ }
64
+ HTTP.get("#{host}/api/v1/profile", params: params).parse
65
+ end
66
+
67
+ private
68
+
69
+ def host
70
+ "https://#{Reach5.configuration.customer_domain}"
71
+ end
72
+
73
+ def access_token
74
+ @access_token ||= get_access_token.fetch("auth").fetch("accessToken")
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,23 @@
1
+ # Configure Reach5
2
+ module Reach5
3
+ # Global configuration for API calls.
4
+ class Configuration
5
+ attr_accessor :customer_domain
6
+ attr_accessor :client_key
7
+ attr_accessor :client_secret
8
+
9
+ def initialize
10
+ @customer_domain = "NO_CUSTOMER_DOMAIN_SET"
11
+ @client_key = "NO_CLIENT_KEY_SET"
12
+ @client_secret = "NO_SECRET_ACCESS_TOKEN_SET"
13
+ end
14
+ end
15
+
16
+ class << self
17
+ attr_accessor :configuration
18
+ end
19
+
20
+ def self.configure(&block)
21
+ (self.configuration ||= Configuration.new).tap(&block)
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Reach5
2
+ VERSION = "0.1.0".freeze
3
+ end
data/lib/reach5.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "http"
2
+
3
+ require "reach5/version"
4
+ require "reach5/configuration"
5
+ require "reach5/api"
6
+
7
+ # Namespace.
8
+ module Reach5
9
+ end
data/reach5.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "reach5/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "reach5"
8
+ spec.version = Reach5::VERSION
9
+ spec.authors = ["Sunny Ripert"]
10
+ spec.email = ["sunny@sunfox.org"]
11
+
12
+ spec.summary = "Integrate to Reach5"
13
+ spec.description = "Integrate to the Reach5 Customer Identity Management " \
14
+ "Platform"
15
+ spec.homepage = "http://github.com/sunny/reach5"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ .reject { |f| f.match(%r{^(spec)/}) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "http", "2.0.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.12"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "webmock", "~> 2.1"
28
+ spec.add_development_dependency "rubocop", "~> 0.42"
29
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reach5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sunny Ripert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.42'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.42'
97
+ description: Integrate to the Reach5 Customer Identity Management Platform
98
+ email:
99
+ - sunny@sunfox.org
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rubocop.yml"
106
+ - ".ruby-version"
107
+ - CHANGELOG.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - lib/reach5.rb
115
+ - lib/reach5/api.rb
116
+ - lib/reach5/configuration.rb
117
+ - lib/reach5/version.rb
118
+ - reach5.gemspec
119
+ homepage: http://github.com/sunny/reach5
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.5.1
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Integrate to Reach5
143
+ test_files: []