paychex_api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +24 -0
- data/.simplecov +7 -0
- data/Dockerfile +14 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +42 -10
- data/bin/jenkins +15 -0
- data/build.sh +5 -0
- data/docker-compose.yml +18 -0
- data/lib/paychex_api.rb +9 -0
- data/lib/paychex_api/api_array.rb +46 -43
- data/lib/paychex_api/client.rb +76 -46
- data/lib/paychex_api/client/associations.rb +10 -0
- data/lib/paychex_api/client/companies.rb +7 -4
- data/lib/paychex_api/client/workers.rb +0 -2
- data/lib/paychex_api/version.rb +1 -1
- data/paychex_api.gemspec +22 -20
- data/spec/paychex_api/api_array_spec.rb +54 -0
- data/spec/paychex_api/client/associations_spec.rb +13 -0
- data/spec/paychex_api/client/companies_spec.rb +12 -7
- data/spec/paychex_api/client/workers_spec.rb +15 -10
- data/spec/paychex_api/client_spec.rb +13 -13
- data/spec/paychex_api/paychex_api_spec.rb +16 -0
- data/spec/support/fake_paychex.rb +16 -9
- data/spec/test_helper.rb +3 -4
- metadata +98 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9de0f7cad757b537924ef7f2f44d900c35e5012d
|
4
|
+
data.tar.gz: d309d3026ae13f12cfb9007522e8740a207278c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e41269cc0be06d85a2e81a1ea1322ec56c49e887febe6aeb6bb35cada13976a6500085c70f91f9f5033780da7b4d5fedddf1ad4cc0447213652a0bf2600cb3a7
|
7
|
+
data.tar.gz: bd2845c4f9e0682e580cc1b9a6657702f3771cf195cbae783cad649ab713864709b6cb7dd94a56a2b5b6f8b2a4cf8e556a2e7528eb64249e2a923acde928b36d
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- 'bin/**/*'
|
4
|
+
- 'node_modules/**/*'
|
5
|
+
- 'vendor/**/*'
|
6
|
+
Metrics/ClassLength:
|
7
|
+
Max: 150
|
8
|
+
Metrics/LineLength:
|
9
|
+
Max: 120
|
10
|
+
Style/Documentation:
|
11
|
+
Enabled: false
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Exclude:
|
14
|
+
- 'paychex_api.gemspec'
|
15
|
+
- 'spec/**/*'
|
16
|
+
Style/FrozenStringLiteralComment:
|
17
|
+
Enabled: false
|
18
|
+
Style/SymbolArray:
|
19
|
+
Enabled: false
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Exclude:
|
22
|
+
- spec/**/*
|
23
|
+
Naming/AccessorMethodName:
|
24
|
+
Enabled: false
|
data/.simplecov
ADDED
data/Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
FROM ruby:2.5.0
|
2
|
+
|
3
|
+
RUN apt-get update
|
4
|
+
|
5
|
+
RUN mkdir -p /usr/src/app
|
6
|
+
COPY Gemfile /usr/src/app/
|
7
|
+
COPY Gemfile.lock /usr/src/app/
|
8
|
+
COPY paychex_api.gemspec /usr/src/app/
|
9
|
+
COPY /lib/paychex_api/version.rb /usr/src/app/lib/paychex_api/
|
10
|
+
|
11
|
+
WORKDIR /usr/src/app
|
12
|
+
RUN bundle install --system
|
13
|
+
|
14
|
+
COPY . /usr/src/app/
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
gemspec
|
2
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
5
|
-
faraday (~> 0.9.
|
6
|
-
faraday_middleware (~> 0.9.
|
4
|
+
paychex_api (0.0.3)
|
5
|
+
faraday (~> 0.9.2)
|
6
|
+
faraday_middleware (~> 0.9.2)
|
7
7
|
footrest (>= 0.5.1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (5.
|
12
|
+
activesupport (5.2.0)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (
|
14
|
+
i18n (>= 0.7, < 2)
|
15
15
|
minitest (~> 5.1)
|
16
16
|
tzinfo (~> 1.1)
|
17
17
|
addressable (2.5.2)
|
18
18
|
public_suffix (>= 2.0.2, < 4.0)
|
19
|
+
ast (2.4.0)
|
19
20
|
byebug (8.2.5)
|
20
21
|
coderay (1.1.2)
|
21
22
|
concurrent-ruby (1.0.5)
|
22
23
|
crack (0.4.3)
|
23
24
|
safe_yaml (~> 1.0.0)
|
24
25
|
diff-lcs (1.3)
|
26
|
+
docile (1.3.0)
|
25
27
|
faraday (0.9.2)
|
26
28
|
multipart-post (>= 1.2, < 3)
|
27
29
|
faraday_middleware (0.9.2)
|
@@ -30,13 +32,24 @@ GEM
|
|
30
32
|
activesupport (>= 3.0.0)
|
31
33
|
faraday (~> 0.9.0)
|
32
34
|
link_header (>= 0.0.7)
|
35
|
+
gergich (0.2.2)
|
36
|
+
httparty (~> 0.6)
|
37
|
+
sqlite3 (~> 1.3)
|
33
38
|
hashdiff (0.3.7)
|
34
|
-
|
39
|
+
httparty (0.16.2)
|
40
|
+
multi_xml (>= 0.5.2)
|
41
|
+
i18n (1.0.1)
|
35
42
|
concurrent-ruby (~> 1.0)
|
43
|
+
json (2.1.0)
|
36
44
|
link_header (0.0.8)
|
37
45
|
method_source (0.9.0)
|
38
|
-
minitest (5.11.
|
46
|
+
minitest (5.11.3)
|
47
|
+
multi_xml (0.6.0)
|
39
48
|
multipart-post (2.0.0)
|
49
|
+
parallel (1.12.1)
|
50
|
+
parser (2.5.1.0)
|
51
|
+
ast (~> 2.4.0)
|
52
|
+
powerpack (0.1.1)
|
40
53
|
pry (0.11.3)
|
41
54
|
coderay (~> 1.1.0)
|
42
55
|
method_source (~> 0.9.0)
|
@@ -44,6 +57,7 @@ GEM
|
|
44
57
|
rack (1.6.8)
|
45
58
|
rack-protection (1.5.3)
|
46
59
|
rack
|
60
|
+
rainbow (3.0.0)
|
47
61
|
rake (0.9.6)
|
48
62
|
rspec (2.99.0)
|
49
63
|
rspec-core (~> 2.99.0)
|
@@ -53,15 +67,30 @@ GEM
|
|
53
67
|
rspec-expectations (2.99.2)
|
54
68
|
diff-lcs (>= 1.1.3, < 2.0)
|
55
69
|
rspec-mocks (2.99.4)
|
70
|
+
rubocop (0.54.0)
|
71
|
+
parallel (~> 1.10)
|
72
|
+
parser (>= 2.5)
|
73
|
+
powerpack (~> 0.1)
|
74
|
+
rainbow (>= 2.2.2, < 4.0)
|
75
|
+
ruby-progressbar (~> 1.7)
|
76
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
77
|
+
ruby-progressbar (1.9.0)
|
56
78
|
safe_yaml (1.0.4)
|
79
|
+
simplecov (0.16.1)
|
80
|
+
docile (~> 1.1)
|
81
|
+
json (>= 1.8, < 3)
|
82
|
+
simplecov-html (~> 0.10.0)
|
83
|
+
simplecov-html (0.10.2)
|
57
84
|
sinatra (1.4.8)
|
58
85
|
rack (~> 1.5)
|
59
86
|
rack-protection (~> 1.4)
|
60
87
|
tilt (>= 1.3, < 3)
|
88
|
+
sqlite3 (1.3.13)
|
61
89
|
thread_safe (0.3.6)
|
62
90
|
tilt (1.4.1)
|
63
|
-
tzinfo (1.2.
|
91
|
+
tzinfo (1.2.5)
|
64
92
|
thread_safe (~> 0.1)
|
93
|
+
unicode-display_width (1.3.2)
|
65
94
|
webmock (1.22.6)
|
66
95
|
addressable (>= 2.3.6)
|
67
96
|
crack (>= 0.3.2)
|
@@ -71,15 +100,18 @@ PLATFORMS
|
|
71
100
|
ruby
|
72
101
|
|
73
102
|
DEPENDENCIES
|
74
|
-
bridge_api!
|
75
103
|
bundler (~> 1.0, >= 1.0.0)
|
76
104
|
byebug (~> 8.2.2)
|
105
|
+
gergich (~> 0.2.2)
|
106
|
+
paychex_api!
|
77
107
|
pry (~> 0)
|
78
108
|
rake (~> 0)
|
79
109
|
rspec (~> 2.6)
|
110
|
+
rubocop (~> 0.54.0)
|
111
|
+
simplecov (~> 0.16.1)
|
80
112
|
sinatra (~> 1.0)
|
81
113
|
tilt (~> 1.3, >= 1.3.4)
|
82
114
|
webmock (~> 1.22.6)
|
83
115
|
|
84
116
|
BUNDLED WITH
|
85
|
-
1.16.
|
117
|
+
1.16.1
|
data/bin/jenkins
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set +e
|
4
|
+
EXIT_CODES=0
|
5
|
+
|
6
|
+
echo "Analyzing ruby code with rubocop"
|
7
|
+
bundle exec gergich capture rubocop "bundle exec rubocop --fail-level autocorrect"
|
8
|
+
EXIT_CODES=$(($EXIT_CODES + $?))
|
9
|
+
|
10
|
+
echo 'Running ruby specs'
|
11
|
+
bundle exec rspec
|
12
|
+
EXIT_CODES=$(($EXIT_CODES + $?))
|
13
|
+
|
14
|
+
bundle exec gergich publish
|
15
|
+
exit $EXIT_CODES
|
data/build.sh
ADDED
data/docker-compose.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
version: '2'
|
2
|
+
|
3
|
+
services:
|
4
|
+
web:
|
5
|
+
build:
|
6
|
+
context: .
|
7
|
+
dockerfile: ./Dockerfile
|
8
|
+
environment:
|
9
|
+
APP_DOMAIN: web
|
10
|
+
GERGICH_KEY: "${GERGICH_KEY}"
|
11
|
+
GERRIT_PROJECT: "${GERRIT_PROJECT}"
|
12
|
+
GERRIT_HOST: "${GERRIT_HOST}"
|
13
|
+
GERRIT_BRANCH: "${GERRIT_BRANCH}"
|
14
|
+
volumes:
|
15
|
+
- "coverage:/usr/src/app/coverage"
|
16
|
+
|
17
|
+
volumes:
|
18
|
+
coverage: {}
|
data/lib/paychex_api.rb
CHANGED
@@ -3,24 +3,27 @@ module PaychexAPI
|
|
3
3
|
class ApiArray
|
4
4
|
include Enumerable
|
5
5
|
|
6
|
+
MAX_PAGES = 100
|
7
|
+
|
6
8
|
@next_page = nil
|
7
9
|
@prev_page = nil
|
8
10
|
|
9
|
-
attr_reader :status, :headers, :members, :links, :metadata
|
11
|
+
attr_reader :status, :headers, :members, :links, :metadata
|
12
|
+
attr_writer :next_page
|
10
13
|
|
11
14
|
def self.process_response(response, api_client)
|
12
15
|
ApiArray.new(response, api_client)
|
13
16
|
end
|
14
17
|
|
15
18
|
def initialize(response, api_client)
|
16
|
-
@meta_fields = %w
|
19
|
+
@meta_fields = %w[metadata links]
|
17
20
|
@api_client = api_client
|
18
21
|
@links = []
|
19
22
|
@metadata = {}
|
20
23
|
case response.status
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
when *((200..206).to_a + [302])
|
25
|
+
apply_response_metadata(response)
|
26
|
+
@members = get_response_content(response)
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
@@ -28,16 +31,16 @@ module PaychexAPI
|
|
28
31
|
@members.length
|
29
32
|
end
|
30
33
|
|
31
|
-
def [](
|
32
|
-
@members[
|
34
|
+
def [](index)
|
35
|
+
@members[index]
|
33
36
|
end
|
34
37
|
|
35
38
|
def last
|
36
39
|
@members.last
|
37
40
|
end
|
38
41
|
|
39
|
-
def each
|
40
|
-
@members.each { |member|
|
42
|
+
def each
|
43
|
+
@members.each { |member| yield(member) }
|
41
44
|
end
|
42
45
|
|
43
46
|
def pages?
|
@@ -48,33 +51,40 @@ module PaychexAPI
|
|
48
51
|
load_page(@next_page)
|
49
52
|
end
|
50
53
|
|
51
|
-
def each_page
|
52
|
-
|
54
|
+
def each_page
|
55
|
+
yield(@members, @linked, @meta)
|
53
56
|
while @next_page
|
54
57
|
response = get_page(@next_page)
|
55
58
|
apply_response_metadata(response, false)
|
56
59
|
@members = get_response_content(response)
|
57
|
-
|
60
|
+
yield(@members, @linked, @meta)
|
58
61
|
end
|
59
62
|
@link_hash = {}
|
60
63
|
end
|
61
64
|
|
62
65
|
def all_pages!
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@members.concat(get_response_content(response))
|
67
|
-
while @next_page
|
68
|
-
response = get_page(@next_page)
|
69
|
-
apply_response_metadata(response)
|
70
|
-
@members.concat(get_response_content(response))
|
71
|
-
end
|
72
|
-
end
|
66
|
+
return self unless pages?
|
67
|
+
combine_page
|
68
|
+
combine_pages
|
73
69
|
self
|
74
70
|
end
|
75
71
|
|
76
72
|
private
|
77
73
|
|
74
|
+
def combine_pages
|
75
|
+
counter = 0
|
76
|
+
while @next_page && counter <= MAX_PAGES
|
77
|
+
combine_page
|
78
|
+
counter += 1
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def combine_page
|
83
|
+
response = get_page(@next_page)
|
84
|
+
apply_response_metadata(response)
|
85
|
+
@members.concat(get_response_content(response))
|
86
|
+
end
|
87
|
+
|
78
88
|
def get_page(url, params = {})
|
79
89
|
query = URI.parse(url).query
|
80
90
|
p = CGI.parse(query).merge(params)
|
@@ -93,15 +103,13 @@ module PaychexAPI
|
|
93
103
|
def get_response_content(response)
|
94
104
|
return [] unless response.body.is_a?(Hash)
|
95
105
|
content = response.body['content']
|
96
|
-
|
97
|
-
return content
|
98
|
-
end
|
106
|
+
return content unless content.empty?
|
99
107
|
[]
|
100
108
|
end
|
101
109
|
|
102
110
|
def apply_response_metadata(response, concat = true)
|
103
111
|
unless concat
|
104
|
-
@links =
|
112
|
+
@links = []
|
105
113
|
@metadata = {}
|
106
114
|
end
|
107
115
|
@status = response.status
|
@@ -113,31 +121,26 @@ module PaychexAPI
|
|
113
121
|
end
|
114
122
|
|
115
123
|
def init_linked(response)
|
116
|
-
|
117
|
-
|
118
|
-
end
|
124
|
+
return nil unless response.body.is_a?(Hash) && response.body.key?('links')
|
125
|
+
@links = @links.concat(response.body['links'])
|
119
126
|
end
|
120
127
|
|
121
128
|
def init_meta(response)
|
122
|
-
|
123
|
-
|
124
|
-
end
|
129
|
+
return nil unless response.body.is_a?(Hash) && response.body.key?('metadata')
|
130
|
+
@metadata = response.body['metadata']
|
125
131
|
end
|
126
132
|
|
127
133
|
def init_pages(response)
|
128
|
-
|
129
|
-
@prev_page = nil
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
@prev_page = link['href']
|
137
|
-
end
|
134
|
+
return nil unless response.body.is_a?(Hash) && response.body.key?('links')
|
135
|
+
@next_page, @prev_page = nil
|
136
|
+
response.body['links'].each do |link|
|
137
|
+
case link['rel']
|
138
|
+
when 'next'
|
139
|
+
@next_page = link['href']
|
140
|
+
when 'prev'
|
141
|
+
@prev_page = link['href']
|
138
142
|
end
|
139
143
|
end
|
140
144
|
end
|
141
|
-
|
142
145
|
end
|
143
146
|
end
|
data/lib/paychex_api/client.rb
CHANGED
@@ -11,68 +11,98 @@ require 'paychex_api/api_array'
|
|
11
11
|
|
12
12
|
module PaychexAPI
|
13
13
|
class Client < Footrest::Client
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
ORGANIZATIONS_PATH = '/organizations'
|
18
|
-
JOB_TITLES_PATH = '/jobtitles'
|
19
|
-
WORKER_STATUSES_PATH = '/workerstatuses'
|
20
|
-
WORKERS_PATH = '/workers'
|
21
|
-
COMMUNICATIONS_PATH = '/communications'
|
22
|
-
COMPENSATION_PATH = '/compensation'
|
23
|
-
DIRECT_DEPOSITS_PATH = '/directdeposits'
|
24
|
-
PAY_PERIODS_PATH = '/payperiods'
|
25
|
-
PAY_COMPONENTS_PATH = '/paycomponents'
|
26
|
-
CHECKS_PATH = '/checks'
|
27
|
-
OAUTH_TOKEN_PATH = '/auth/oauth/v2/token'
|
14
|
+
API_PATH = ''.freeze
|
15
|
+
COMPANIES_PATH = '/companies'.freeze
|
16
|
+
ASSOCIATIONS_PATH = '/'.freeze
|
17
|
+
ORGANIZATIONS_PATH = '/organizations'.freeze
|
18
|
+
JOB_TITLES_PATH = '/jobtitles'.freeze
|
19
|
+
WORKER_STATUSES_PATH = '/workerstatuses'.freeze
|
20
|
+
WORKERS_PATH = '/workers'.freeze
|
21
|
+
COMMUNICATIONS_PATH = '/communications'.freeze
|
22
|
+
COMPENSATION_PATH = '/compensation'.freeze
|
23
|
+
DIRECT_DEPOSITS_PATH = '/directdeposits'.freeze
|
24
|
+
PAY_PERIODS_PATH = '/payperiods'.freeze
|
25
|
+
PAY_COMPONENTS_PATH = '/paycomponents'.freeze
|
26
|
+
CHECKS_PATH = '/checks'.freeze
|
27
|
+
OAUTH_TOKEN_PATH = '/auth/oauth/v2/token'.freeze
|
28
28
|
|
29
29
|
attr_reader :authorization
|
30
30
|
|
31
31
|
Dir[File.dirname(__FILE__) + '/client/*.rb'].each do |file|
|
32
32
|
require file
|
33
|
-
include
|
33
|
+
include const_get(File.basename(file).gsub('.rb', '').split('_').map(&:capitalize).join('').to_s)
|
34
34
|
end
|
35
35
|
|
36
36
|
# Override Footrest request for ApiArray support
|
37
37
|
def request(method, &block)
|
38
|
-
if @authorization.blank? || @authorization['expiration'] <=
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
ApiArray::process_response(connection.send(method, &block), self)
|
38
|
+
authorize if @authorization.blank? || @authorization['expiration'] <= Time.now - 30.seconds
|
39
|
+
connection.headers[:authorization] = "Bearer #{@authorization['access_token']}"
|
40
|
+
ApiArray.process_response(connection.send(method, &block), self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def authorize
|
44
|
+
response = default_faraday.post(
|
45
|
+
OAUTH_TOKEN_PATH,
|
46
|
+
client_id: config[:client_id],
|
47
|
+
client_secret: config[:client_secret],
|
48
|
+
grant_type: 'client_credentials'
|
49
|
+
)
|
50
|
+
@authorization = response.body
|
51
|
+
@authorization['expiration'] = Time.now + @authorization['expires_in'].to_i.seconds
|
53
52
|
end
|
54
53
|
|
55
54
|
def set_connection(config)
|
56
55
|
config[:logger] = config[:logging] if config[:logging]
|
57
|
-
@connection =
|
56
|
+
@connection = default_faraday
|
57
|
+
end
|
58
|
+
|
59
|
+
def faraday_default_use(faraday)
|
60
|
+
faraday.use Footrest::ParseJson, content_type: /\bjson$/
|
61
|
+
faraday.use Footrest::RaiseFootrestErrors
|
62
|
+
faraday.use Footrest::Pagination
|
63
|
+
faraday.use Footrest::FollowRedirects, limit: 5 if config[:follow_redirects]
|
64
|
+
faraday
|
65
|
+
end
|
66
|
+
|
67
|
+
def faraday_default_headers(faraday)
|
68
|
+
faraday.headers[:accept] = 'application/json'
|
69
|
+
faraday.headers[:user_agent] = 'Footrest'
|
70
|
+
faraday
|
71
|
+
end
|
72
|
+
|
73
|
+
def faraday_default_request(faraday)
|
74
|
+
faraday.request :multipart
|
75
|
+
faraday.request :url_encoded
|
76
|
+
faraday
|
77
|
+
end
|
78
|
+
|
79
|
+
def faraday_logger(faraday)
|
80
|
+
if config[:logger] == true
|
81
|
+
faraday.response :logger
|
82
|
+
elsif config[:logger]
|
83
|
+
faraday.use Faraday::Response::Logger, config[:logger]
|
84
|
+
end
|
85
|
+
faraday
|
86
|
+
end
|
87
|
+
|
88
|
+
def faraday_proxy(faraday)
|
89
|
+
faraday.proxy PaychexAPI.proxy if PaychexAPI.proxy
|
90
|
+
faraday
|
91
|
+
end
|
92
|
+
|
93
|
+
def faraday_config(faraday)
|
94
|
+
faraday = faraday_logger(faraday)
|
95
|
+
faraday = faraday_default_request(faraday)
|
96
|
+
faraday = faraday_default_use(faraday)
|
97
|
+
faraday = faraday_default_headers(faraday)
|
98
|
+
faraday = faraday_proxy(faraday)
|
99
|
+
faraday.adapter Faraday.default_adapter
|
100
|
+
faraday
|
58
101
|
end
|
59
102
|
|
60
|
-
def
|
103
|
+
def default_faraday
|
61
104
|
Faraday.new(url: config[:prefix]) do |faraday|
|
62
|
-
faraday
|
63
|
-
faraday.request :url_encoded
|
64
|
-
if config[:logger] == true
|
65
|
-
faraday.response :logger
|
66
|
-
elsif config[:logger]
|
67
|
-
faraday.use Faraday::Response::Logger, config[:logger]
|
68
|
-
end
|
69
|
-
faraday.use Footrest::FollowRedirects, limit: 5 unless config[:follow_redirects] == false
|
70
|
-
faraday.adapter Faraday.default_adapter
|
71
|
-
faraday.use Footrest::ParseJson, :content_type => /\bjson$/
|
72
|
-
faraday.use Footrest::RaiseFootrestErrors
|
73
|
-
faraday.use Footrest::Pagination
|
74
|
-
faraday.headers[:accept] = "application/json"
|
75
|
-
faraday.headers[:user_agent] = "Footrest"
|
105
|
+
faraday_config(faraday)
|
76
106
|
end
|
77
107
|
end
|
78
108
|
end
|