adp_client 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: 8a6ecd5572e30c5feaa7651120f6d63fea35a7b5
4
+ data.tar.gz: b2a37a1d06a87df81eb8af9ca6be6c08fb03efb0
5
+ SHA512:
6
+ metadata.gz: d223d0315b28890253f319d09c61e135a30ba1b2cb5e35d27f83ddbe22e0ad317f5091605a177b501dc55d49eb6979a6a30a79e9852e8afbf49fd191e6c8efa5
7
+ data.tar.gz: 7a91c9e7a13c7ec4eab45c62ea5e74428e7970234dc311b08a44467fd7e652ed445cba87ac57017b49ad8ff4e92f2b1235126647f012f9d75d7bcf64f743baab
@@ -0,0 +1,45 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: circleci/ruby:2.4.1-node-browsers
6
+ working_directory: ~/repo
7
+ steps:
8
+ - checkout
9
+ - restore_cache:
10
+ keys:
11
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
12
+ # fallback to using the latest cache if no exact match is found
13
+ - v1-dependencies-
14
+ - run:
15
+ name: install dependencies
16
+ command: |
17
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
18
+ - run:
19
+ name: Setup Code Climate test-reporter
20
+ command: |
21
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
22
+ chmod +x ./cc-test-reporter
23
+ - save_cache:
24
+ paths:
25
+ - ./vendor/bundle
26
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
27
+ - run:
28
+ name: run tests
29
+ command: |
30
+ ./cc-test-reporter before-build
31
+ mkdir /tmp/test-results
32
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
33
+
34
+ bundle exec rspec --format progress \
35
+ --format RspecJunitFormatter \
36
+ --out /tmp/test-results/rspec.xml \
37
+ --format progress \
38
+ -- \
39
+ $TEST_FILES
40
+ ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
41
+ - store_test_results:
42
+ path: /tmp/test-results
43
+ - store_artifacts:
44
+ path: /tmp/test-results
45
+ destination: test-results
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
@@ -0,0 +1,240 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+ UseCache: false
4
+ Layout/DotPosition:
5
+ Description: Checks the position of the dot in multi-line method calls.
6
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
7
+ Enabled: true
8
+ EnforcedStyle: trailing
9
+ SupportedStyles:
10
+ - leading
11
+ - trailing
12
+ Layout/EmptyLineAfterMagicComment:
13
+ Description: 'Add an empty line after magic comments to separate them from code.'
14
+ StyleGuide: '#separate-magic-comments-from-code'
15
+ Enabled: false
16
+ Lint/AmbiguousBlockAssociation:
17
+ Exclude:
18
+ - "spec/**/*"
19
+ Naming/AccessorMethodName:
20
+ Description: Check the naming of accessor methods for get_/set_.
21
+ Enabled: false
22
+ Naming/FileName:
23
+ Description: Use snake_case for source file names.
24
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
25
+ Enabled: false
26
+ Exclude: []
27
+ Naming/PredicateName:
28
+ Description: Check the names of predicate methods.
29
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
30
+ Enabled: true
31
+ NamePrefix:
32
+ - is_
33
+ - has_
34
+ - have_
35
+ NamePrefixBlacklist:
36
+ - is_
37
+ Exclude:
38
+ - spec/**/*
39
+ Style/CollectionMethods:
40
+ Description: Preferred collection methods.
41
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
42
+ Enabled: true
43
+ PreferredMethods:
44
+ collect: map
45
+ collect!: map!
46
+ find: detect
47
+ find_all: select
48
+ reduce: inject
49
+ Style/GuardClause:
50
+ Description: Check for conditionals that can be replaced with guard clauses
51
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
52
+ Enabled: false
53
+ MinBodyLength: 1
54
+ Style/IfUnlessModifier:
55
+ Description: Favor modifier if/unless usage when you have a single-line body.
56
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
57
+ Enabled: false
58
+ MaxLineLength: 80
59
+ Style/OptionHash:
60
+ Description: Don't use option hashes when you can use keyword arguments.
61
+ Enabled: false
62
+ Style/PercentLiteralDelimiters:
63
+ Description: Use `%`-literal delimiters consistently
64
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
65
+ Enabled: false
66
+ PreferredDelimiters:
67
+ "%": "()"
68
+ "%i": "()"
69
+ "%q": "()"
70
+ "%Q": "()"
71
+ "%r": "{}"
72
+ "%s": "()"
73
+ "%w": "()"
74
+ "%W": "()"
75
+ "%x": "()"
76
+ Style/RaiseArgs:
77
+ Description: Checks the arguments passed to raise/fail.
78
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
79
+ Enabled: false
80
+ EnforcedStyle: exploded
81
+ SupportedStyles:
82
+ - compact
83
+ - exploded
84
+ Style/SignalException:
85
+ Description: Checks for proper usage of fail and raise.
86
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
87
+ Enabled: true
88
+ EnforcedStyle: semantic
89
+ SupportedStyles:
90
+ - only_raise
91
+ - only_fail
92
+ - semantic
93
+ Style/SingleLineBlockParams:
94
+ Description: Enforces the names of some block params.
95
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
96
+ Enabled: false
97
+ Methods:
98
+ - reduce:
99
+ - a
100
+ - e
101
+ - inject:
102
+ - a
103
+ - e
104
+ Style/SingleLineMethods:
105
+ Description: Avoid single-line methods.
106
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
107
+ Enabled: false
108
+ AllowIfMethodIsEmpty: true
109
+ Style/StringLiterals:
110
+ Description: Checks if uses of quotes match the configured preference.
111
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
112
+ Enabled: true
113
+ EnforcedStyle: double_quotes
114
+ SupportedStyles:
115
+ - single_quotes
116
+ - double_quotes
117
+ Style/StringLiteralsInInterpolation:
118
+ Description: Checks if uses of quotes inside expressions in interpolated strings
119
+ match the configured preference.
120
+ Enabled: true
121
+ EnforcedStyle: single_quotes
122
+ SupportedStyles:
123
+ - single_quotes
124
+ - double_quotes
125
+ Style/TrailingCommaInArguments:
126
+ Description: 'Checks for trailing comma in argument lists.'
127
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
128
+ Enabled: true
129
+ EnforcedStyleForMultiline: no_comma
130
+ Style/TrailingCommaInLiteral:
131
+ Description: 'Checks for trailing comma in array and hash literals.'
132
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
133
+ Enabled: true
134
+ EnforcedStyleForMultiline: no_comma
135
+ Metrics/AbcSize:
136
+ Description: A calculated magnitude based on number of assignments, branches, and
137
+ conditions.
138
+ Enabled: false
139
+ Max: 15
140
+ Metrics/ClassLength:
141
+ Description: Avoid classes longer than 100 lines of code.
142
+ Enabled: false
143
+ CountComments: false
144
+ Max: 100
145
+ Metrics/ModuleLength:
146
+ CountComments: false
147
+ Max: 100
148
+ Description: Avoid modules longer than 100 lines of code.
149
+ Enabled: false
150
+ Metrics/CyclomaticComplexity:
151
+ Description: A complexity metric that is strongly correlated to the number of test
152
+ cases needed to validate a method.
153
+ Enabled: false
154
+ Max: 6
155
+ Metrics/MethodLength:
156
+ Description: Avoid methods longer than 10 lines of code.
157
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
158
+ Enabled: false
159
+ CountComments: false
160
+ Max: 10
161
+ Metrics/ParameterLists:
162
+ Description: Avoid parameter lists longer than three or four parameters.
163
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
164
+ Enabled: false
165
+ Max: 5
166
+ CountKeywordArgs: true
167
+ Metrics/PerceivedComplexity:
168
+ Description: A complexity metric geared towards measuring complexity for a human
169
+ reader.
170
+ Enabled: false
171
+ Max: 7
172
+ Lint/AssignmentInCondition:
173
+ Description: Don't use assignment in conditions.
174
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
175
+ Enabled: false
176
+ AllowSafeAssignment: true
177
+ Style/InlineComment:
178
+ Description: Avoid inline comments.
179
+ Enabled: false
180
+ Style/Alias:
181
+ Description: Use alias_method instead of alias.
182
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
183
+ Enabled: false
184
+ Style/Documentation:
185
+ Description: Document classes and non-namespace modules.
186
+ Enabled: false
187
+ Style/DoubleNegation:
188
+ Description: Checks for uses of double negation (!!).
189
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
190
+ Enabled: false
191
+ Style/EachWithObject:
192
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
193
+ Enabled: false
194
+ Style/EmptyLiteral:
195
+ Description: Prefer literals to Array.new/Hash.new/String.new.
196
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
197
+ Enabled: false
198
+ Style/ModuleFunction:
199
+ Description: Checks for usage of `extend self` in modules.
200
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
201
+ Enabled: false
202
+ Style/OneLineConditional:
203
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
204
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
205
+ Enabled: false
206
+ Style/PerlBackrefs:
207
+ Description: Avoid Perl-style regex back references.
208
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
209
+ Enabled: false
210
+ Style/Send:
211
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
212
+ may overlap with existing methods.
213
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
214
+ Enabled: false
215
+ Style/SpecialGlobalVars:
216
+ Description: Avoid Perl-style global variables.
217
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
218
+ Enabled: false
219
+ Style/VariableInterpolation:
220
+ Description: Don't interpolate global, instance and class variables directly in
221
+ strings.
222
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
223
+ Enabled: false
224
+ Style/WhenThen:
225
+ Description: Use when x then ... for one-line cases.
226
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
227
+ Enabled: false
228
+ Lint/EachWithObjectArgument:
229
+ Description: Check for immutable argument given to each_with_object.
230
+ Enabled: true
231
+ Lint/HandleExceptions:
232
+ Description: Don't suppress exception.
233
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
234
+ Enabled: false
235
+ Lint/LiteralAsCondition:
236
+ Description: This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.
237
+ Enabled: false
238
+ Lint/LiteralInInterpolation:
239
+ Description: Checks for literals used in interpolation.
240
+ Enabled: false
data/.hound.yml ADDED
@@ -0,0 +1,3 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
3
+ fail_on_violations: true
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,41 @@
1
+ inherit_from:
2
+ - .hound-rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.4
6
+ Exclude:
7
+ - bin/*
8
+ Layout/DotPosition:
9
+ Description: Checks the position of the dot in multi-line method calls.
10
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
11
+ Enabled: true
12
+ EnforcedStyle: leading
13
+ SupportedStyles:
14
+ - leading
15
+ - trailing
16
+ Metrics/BlockLength:
17
+ Enabled: false
18
+ Style/AndOr:
19
+ Description: Use &&/|| instead of and/or.
20
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or
21
+ Enabled: true
22
+ EnforcedStyle: conditionals
23
+ SupportedStyles:
24
+ - always
25
+ - conditionals
26
+ Style/ClassAndModuleChildren:
27
+ Enabled: true
28
+ EnforcedStyle: nested
29
+ SupportedStyles:
30
+ - compact
31
+ - nested
32
+ Style/MultilineIfModifier:
33
+ Enabled: false
34
+ Style/StringLiterals:
35
+ Description: Checks if uses of quotes match the configured preference.
36
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
37
+ Enabled: true
38
+ EnforcedStyle: single_quotes
39
+ SupportedStyles:
40
+ - single_quotes
41
+ - double_quotes
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.3
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at joe@westernmilling.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
5
+
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,79 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ adp_client (0.1.0)
5
+ httparty
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.2)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ ast (2.4.0)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ diff-lcs (1.3)
16
+ docile (1.1.5)
17
+ hashdiff (0.3.7)
18
+ httparty (0.15.6)
19
+ multi_xml (>= 0.5.2)
20
+ json (2.1.0)
21
+ multi_xml (0.6.0)
22
+ parallel (1.12.1)
23
+ parser (2.4.0.2)
24
+ ast (~> 2.3)
25
+ powerpack (0.1.1)
26
+ public_suffix (3.0.1)
27
+ rainbow (2.2.2)
28
+ rake
29
+ rake (10.5.0)
30
+ rspec (3.7.0)
31
+ rspec-core (~> 3.7.0)
32
+ rspec-expectations (~> 3.7.0)
33
+ rspec-mocks (~> 3.7.0)
34
+ rspec-core (3.7.1)
35
+ rspec-support (~> 3.7.0)
36
+ rspec-expectations (3.7.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.7.0)
39
+ rspec-mocks (3.7.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.7.0)
42
+ rspec-support (3.7.1)
43
+ rspec_junit_formatter (0.3.0)
44
+ rspec-core (>= 2, < 4, != 2.12.0)
45
+ rubocop (0.51.0)
46
+ parallel (~> 1.10)
47
+ parser (>= 2.3.3.1, < 3.0)
48
+ powerpack (~> 0.1)
49
+ rainbow (>= 2.2.2, < 3.0)
50
+ ruby-progressbar (~> 1.7)
51
+ unicode-display_width (~> 1.0, >= 1.0.1)
52
+ ruby-progressbar (1.9.0)
53
+ safe_yaml (1.0.4)
54
+ simplecov (0.15.1)
55
+ docile (~> 1.1.0)
56
+ json (>= 1.8, < 3)
57
+ simplecov-html (~> 0.10.0)
58
+ simplecov-html (0.10.2)
59
+ unicode-display_width (1.3.0)
60
+ webmock (3.2.1)
61
+ addressable (>= 2.3.6)
62
+ crack (>= 0.3.2)
63
+ hashdiff
64
+
65
+ PLATFORMS
66
+ ruby
67
+
68
+ DEPENDENCIES
69
+ adp_client!
70
+ bundler (~> 1.16)
71
+ rake (~> 10.0)
72
+ rspec (~> 3.0)
73
+ rspec_junit_formatter
74
+ rubocop (= 0.51.0)
75
+ simplecov
76
+ webmock
77
+
78
+ BUNDLED WITH
79
+ 1.16.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Western Milling
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Joseph Bridgwater-Rowe
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,52 @@
1
+ [![CircleCI](https://circleci.com/gh/westernmilling/adp_client.svg?style=svg&circle-token=3d5bf2ba7d231f1eae04c432b7775cf5499df917)](https://circleci.com/gh/westernmilling/adp_client)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/bb49c51e2a887464a6e9/maintainability)](https://codeclimate.com/github/westernmilling/adp_client/maintainability)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/bb49c51e2a887464a6e9/test_coverage)](https://codeclimate.com/github/westernmilling/adp_client/test_coverage)
4
+
5
+ # AdpClient
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'adp_client'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install adp_client
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ client = AdpClient.new(
27
+ client_id: ENV['ADP_CLIENT_ID'],
28
+ client_secret: ENV['ADP_CLIENT_SECRET'],
29
+ base_ur: ENV['ADP_API_HOST'],
30
+ pem: File.read(ENV['ADP_SSL_CERT_PATH'])
31
+ )
32
+
33
+ event_data = client.get('events/time/v1/data-collection-entries.process/3d2ae46e-8f94-4fa8-ade1-fe554d93ed71')
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/westernmilling/adp_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
49
+
50
+ ## Code of Conduct
51
+
52
+ Everyone interacting in the AdpClient project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/westernmilling/adp_client/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %w(spec rubocop)
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'adp_client/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'adp_client'
9
+ spec.version = AdpClient::VERSION
10
+ spec.authors = ['Joseph Bridgwater-Rowe']
11
+ spec.email = ['joe@westernmilling.com']
12
+ spec.summary = 'Simple ADP API client'
13
+ spec.homepage = 'https://github.com/westernmilling/adp_client'
14
+ spec.license = 'MIT'
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+ spec.add_runtime_dependency 'httparty'
22
+ spec.add_development_dependency 'bundler', '~> 1.16'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec', '~> 3.0'
25
+ spec.add_development_dependency 'rspec_junit_formatter'
26
+ spec.add_development_dependency 'rubocop', '0.51.0'
27
+ spec.add_development_dependency 'simplecov'
28
+ spec.add_development_dependency 'webmock'
29
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "adp_client"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
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/adp_client.rb ADDED
@@ -0,0 +1,292 @@
1
+ # frozen_string_literal: true
2
+ # $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'adp_client/version'
5
+ require 'httparty'
6
+ require 'logger'
7
+
8
+ ##
9
+ # Basic ADP Api Client
10
+ # Basic Api client that uses client credentials for authentication. The PEM
11
+ # certificate details must contain include the private key appended.
12
+ #
13
+ # @example
14
+ #
15
+ # client = AdpClient.new(
16
+ # client_id: ENV['ADP_CLIENT_ID'],
17
+ # client_secret: ENV['ADP_CLIENT_SECRET'],
18
+ # base_ur: ENV['ADP_API_HOST'],
19
+ # pem: File.read(ENV['ADP_SSL_CERT_PATH'])
20
+ # )
21
+ #
22
+ class AdpClient
23
+ class << self
24
+ attr_accessor :base_url,
25
+ :client_id,
26
+ :client_secret,
27
+ :logger,
28
+ :pem
29
+
30
+ ##
31
+ # Configures default AdpClient settings.
32
+ #
33
+ # @example configuring the client defaults
34
+ # AdpClient.configure do |config|
35
+ # config.base_url = 'https://api.adp.com'
36
+ # config.client_id = 'client_id'
37
+ # config.client_secret = 'client_secret'
38
+ # config.pem = '{cert and key data}'
39
+ # config.logger = Logger.new(STDOUT)
40
+ # end
41
+ #
42
+ # @example using the client
43
+ # client = AdpClient.new
44
+ def configure
45
+ yield self
46
+ true
47
+ end
48
+ end
49
+
50
+ class Error < StandardError
51
+ attr_reader :data
52
+
53
+ def initialize(message, data = nil)
54
+ @data = data
55
+
56
+ super(message)
57
+ end
58
+ end
59
+ class BadRequest < Error; end
60
+ class InvalidRequest < StandardError; end
61
+ class ResourceNotFound < StandardError; end
62
+ class Unauthorized < StandardError; end
63
+ Token = Struct.new(:access_token, :token_type, :expires_in, :scope)
64
+
65
+ def initialize(options = {})
66
+ options = default_options.merge(options)
67
+
68
+ @client_id = options[:client_id]
69
+ @client_secret = options[:client_secret]
70
+ @base_url = options[:base_url]
71
+ @options = { pem: options[:pem] }
72
+ @logger = options.fetch(:logger, Logger.new(STDOUT))
73
+ end
74
+
75
+ ##
76
+ # Default options
77
+ # A {Hash} of default options populate by attributes set during configuration.
78
+ #
79
+ # @return [Hash] containing the default options
80
+ def default_options
81
+ {
82
+ base_url: AdpClient.base_url,
83
+ client_id: AdpClient.client_id,
84
+ client_secret: AdpClient.client_secret,
85
+ logger: AdpClient.logger,
86
+ pem: AdpClient.pem
87
+ }
88
+ end
89
+
90
+ ##
91
+ # OAuth token
92
+ # Performs authentication using client credentials against the ADP Api.
93
+ #
94
+ # @return [Token] token details
95
+ def token
96
+ return @token if @token
97
+
98
+ options = @options.merge(
99
+ body: {
100
+ client_id: @client_id,
101
+ client_secret: @client_secret,
102
+ grant_type: 'client_credentials'
103
+ },
104
+ headers: {
105
+ 'Accept' => 'application/json',
106
+ 'Host' => uri.host
107
+ }
108
+ )
109
+ url = "#{@base_url}/auth/oauth/v2/token"
110
+
111
+ @logger.debug("Request token from #{url}")
112
+
113
+ response = raises_unless_success do
114
+ HTTParty.post(url, options)
115
+ end.parsed_response
116
+
117
+ @token = Token.new(
118
+ *response.values_at('access_token', 'token_type', 'expires_in', 'scope')
119
+ )
120
+ end
121
+
122
+ ##
123
+ # Get a resource
124
+ # Makes a request for a resource from ADP and returns the response as a
125
+ # raw {Hash}.
126
+ #
127
+ # @param [String] the resource endpoint
128
+ # @return [Hash] response data
129
+ def get(resource)
130
+ url = "#{@base_url}/#{resource}"
131
+
132
+ @logger.debug("GET request Url: #{url}")
133
+ @logger.debug("-- Headers: #{base_headers}")
134
+
135
+ raises_unless_success do
136
+ HTTParty
137
+ .get(url, headers: base_headers)
138
+ end.parsed_response
139
+ end
140
+
141
+ ##
142
+ # Post a resource
143
+ # Makes a request to post new resource details to ADP amd returns the
144
+ # response as a raw {Hash}.
145
+ #
146
+ # @param [String] the resource endpoint
147
+ # @param [Hash] the resource data
148
+ # @return [Hash] response data
149
+ def post(resource, data)
150
+ headers = base_headers
151
+ .merge('Content-Type' => 'application/json')
152
+ url = "#{@base_url}/#{resource}"
153
+
154
+ @logger.debug("POST request Url: #{url}")
155
+ @logger.debug("-- Headers: #{headers}")
156
+ @logger.debug("-- JSON #{data.to_json}")
157
+
158
+ raises_unless_success do
159
+ HTTParty
160
+ .post(url, body: data.to_json, headers: headers)
161
+ end.parsed_response
162
+ end
163
+
164
+ protected
165
+
166
+ def base_headers
167
+ {
168
+ 'Accept' => 'application/json',
169
+ 'Authorization' => "Bearer #{token.access_token}",
170
+ 'Connection' => 'Keep-Alive',
171
+ 'Host' => uri.host,
172
+ 'User-Agent' => 'AdpClient'
173
+ }
174
+ end
175
+
176
+ def raises_unless_success
177
+ httparty = yield
178
+
179
+ [
180
+ ErrorHandler,
181
+ InvalidRequestHandler,
182
+ ResourceNotFoundHandler,
183
+ UnauthorizedHandler,
184
+ BadRequestHandler,
185
+ UnknownErrorHandler
186
+ ].each do |response_handler_type|
187
+ response_handler_type.new(httparty).call
188
+ end
189
+
190
+ httparty
191
+ end
192
+
193
+ class BaseErrorHandler
194
+ def initialize(httparty)
195
+ @httparty = httparty
196
+ end
197
+
198
+ def call
199
+ fail error if fail?
200
+ end
201
+ end
202
+
203
+ class ErrorHandler < BaseErrorHandler
204
+ def error
205
+ Error.new(
206
+ @httparty
207
+ .parsed_response
208
+ .fetch('confirmMessage', {})
209
+ .fetch('resourceMessages', [{}])[0]
210
+ .fetch('processMessages', [{}])[0]
211
+ .fetch('userMessage', {})
212
+ .fetch('messageTxt', 'No userMessage messageTxt found'),
213
+ @httparty.parsed_response
214
+ )
215
+ end
216
+
217
+ def fail?
218
+ @httparty.code == 500
219
+ end
220
+ end
221
+
222
+ class BadRequestHandler < BaseErrorHandler
223
+ def error
224
+ BadRequest.new('Looks like a Bad Request', @httparty.parsed_response)
225
+ end
226
+
227
+ def fail?
228
+ @httparty.parsed_response['error'].nil? && @httparty.code == 400
229
+ end
230
+ end
231
+
232
+ class InvalidRequestHandler < BaseErrorHandler
233
+ def error
234
+ InvalidRequest.new(
235
+ format('%s: %s',
236
+ @httparty.parsed_response['error'],
237
+ @httparty.parsed_response['error_description'])
238
+ )
239
+ end
240
+
241
+ def fail?
242
+ @httparty.parsed_response['error'] == 'invalid_request' &&
243
+ @httparty.code == 400
244
+ end
245
+ end
246
+
247
+ class ResourceNotFoundHandler < BaseErrorHandler
248
+ def error
249
+ ResourceNotFound.new(
250
+ @httparty
251
+ .parsed_response
252
+ .fetch('confirmMessage', {})
253
+ .fetch('processMessages', [{}])
254
+ .first
255
+ .fetch('userMessage', {})
256
+ .fetch('messageTxt', 'No userMessage messageTxt found')
257
+ )
258
+ end
259
+
260
+ def fail?
261
+ @httparty.code == 404
262
+ end
263
+ end
264
+
265
+ class UnauthorizedHandler < BaseErrorHandler
266
+ def error
267
+ Unauthorized.new(
268
+ format('%s: %s',
269
+ @httparty.parsed_response['error'],
270
+ @httparty.parsed_response['error_description'])
271
+ )
272
+ end
273
+
274
+ def fail?
275
+ @httparty.code == 401
276
+ end
277
+ end
278
+
279
+ class UnknownErrorHandler < BaseErrorHandler
280
+ def error
281
+ HTTParty::Error.new("Code #{@httparty.code} - #{@httparty.body}")
282
+ end
283
+
284
+ def fail?
285
+ !@httparty.response.is_a?(Net::HTTPSuccess)
286
+ end
287
+ end
288
+
289
+ def uri
290
+ @uri ||= URI.parse(@base_url)
291
+ end
292
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AdpClient
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adp_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Joseph Bridgwater-Rowe
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-02-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '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.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
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: rspec_junit_formatter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
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.51.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.51.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description:
126
+ email:
127
+ - joe@westernmilling.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".circleci/config.yml"
133
+ - ".gitignore"
134
+ - ".hound-rubocop.yml"
135
+ - ".hound.yml"
136
+ - ".rspec"
137
+ - ".rubocop.yml"
138
+ - ".travis.yml"
139
+ - CODE_OF_CONDUCT.md
140
+ - Gemfile
141
+ - Gemfile.lock
142
+ - LICENSE
143
+ - LICENSE.txt
144
+ - README.md
145
+ - Rakefile
146
+ - adp_client.gemspec
147
+ - bin/console
148
+ - bin/setup
149
+ - lib/adp_client.rb
150
+ - lib/adp_client/version.rb
151
+ homepage: https://github.com/westernmilling/adp_client
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.6.14
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Simple ADP API client
175
+ test_files: []