paylocity_web_service 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: 687fc5ccf711675bbc2b78b59ea4e14c17bb43299724e8df0c341824fe01d948
4
- data.tar.gz: c73541d6298ba908050027f73a69dbcfa726ac21d5eedfdd37e7c19a0fbb3472
3
+ metadata.gz: 61c37a8407a937d427a0977f672e8a1cedb242aca0699641756595c377bc4ef6
4
+ data.tar.gz: 6dcbab6fdd29651035fc331d9df52db0dc2f71a50bef1d6c2cdaa83045e6b721
5
5
  SHA512:
6
- metadata.gz: b31b8fee32111c963201c92c7404544a6baf3efd73d21bb3fba04faaa1570b411db3c95d99ef3f288e63e8968360c991216791ef9b11bae47d46ac092d24397e
7
- data.tar.gz: 3074459e1e51a24a12b48b7835fcf4a5301f3a7b324101ff45639f70a86a0016cc45c315efbcf06fce33f7ce378f5d638b0db6db0d25da22ca8ff72c30b2e4d0
6
+ metadata.gz: b6d40b77bcb8c7745e6db01ba7cf96f6c3318df04bf8fc592267a5934ba14d1e55d189cc7832e48ca87681edd1cbb4a33e74a1fdf4abf8aa1805761d76b363f3
7
+ data.tar.gz: bf2a545e9a90521fced8f9676288a230ef31efbcb301b9fa80327566e4e1f3b33f05014a7e93de3d9e580390b751b16fbb44235bf4fd0748e0abb53e2f4252ec
data/.gitignore CHANGED
@@ -7,5 +7,7 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ Gemfile.lock
11
+
10
12
  # rspec failure tracking
11
13
  .rspec_status
@@ -1,8 +1,8 @@
1
1
  module PaylocityWebService
2
2
  class Client
3
3
  module Credentials
4
- def create_client_credential
5
- post("/api/v2/credentials/secrets")
4
+ def create_client_credential(options={})
5
+ post("/api/v2/credentials/secrets", options)
6
6
  end
7
7
  end
8
8
  end
@@ -12,6 +12,10 @@ module PaylocityWebService
12
12
  def create_employee(options={})
13
13
  post("/api/v2/companies/#{company_id}/employees", options)
14
14
  end
15
+
16
+ def create_staging_employee(options={})
17
+ post("/api/v2/weblinkstaging/companies/#{company_id}/employees/newemployees", options)
18
+ end
15
19
  end
16
20
  end
17
21
  end
@@ -0,0 +1,9 @@
1
+ module PaylocityWebService
2
+ class Client
3
+ module Onboardings
4
+ def onboard_employee(options={})
5
+ post("/api/v1/companies/#{company_id}/onboarding/employees", options)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -5,6 +5,7 @@ require 'paylocity_web_service/error'
5
5
  require 'paylocity_web_service/client/companies'
6
6
  require 'paylocity_web_service/client/employees'
7
7
  require 'paylocity_web_service/client/credentials'
8
+ require 'paylocity_web_service/client/onboardings'
8
9
 
9
10
  module PaylocityWebService
10
11
  class Client
@@ -15,6 +16,7 @@ module PaylocityWebService
15
16
  include PaylocityWebService::Client::Employees
16
17
  include PaylocityWebService::Client::Companies
17
18
  include PaylocityWebService::Client::Credentials
19
+ include PaylocityWebService::Client::Onboardings
18
20
 
19
21
  def initialize(options={})
20
22
  options = PaylocityWebService.options.merge(options)
@@ -70,9 +70,9 @@ module PaylocityWebService
70
70
  response = connection.send(method) do |request|
71
71
  case method
72
72
  when :get, :delete
73
- request.url(URI.encode(path), options)
73
+ request.url(path, options)
74
74
  when :post, :put
75
- request.path = URI.encode(path)
75
+ request.path = path
76
76
  request.body = envelope_encrypt(options)
77
77
  end
78
78
  end
@@ -96,7 +96,7 @@ module PaylocityWebService
96
96
  conn.request :retry, max: 2
97
97
  conn.request :json
98
98
 
99
- conn.use PaylocityWebService::Middleware::Response::RaiseError
99
+ # conn.use PaylocityWebService::Middleware::Response::RaiseError
100
100
  conn.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
101
101
  end
102
102
 
@@ -1,67 +1,88 @@
1
1
  module PaylocityWebService
2
- class Error < StandardError
2
+ class Error < StandardError
3
+ attr_accessor :response
4
+
3
5
  # Returns the appropriate PaylocityWebService::Error subclass based
4
6
  # on status and response message
5
7
  #
6
8
  # @param [Hash] response HTTP response
7
9
  # @return [PaylocityWebService::Error]
8
10
  def self.from_response(response)
9
- case response[:status]
11
+ status = response[:status].to_i
12
+
13
+ if klass = case status
10
14
  when 400
11
- raise PaylocityWebService::BadRequest, response_values(response)
15
+ PaylocityWebService::BadRequest
12
16
  when 401
13
- raise PaylocityWebService::ClientError, response_values(response)
17
+ PaylocityWebService::ClientError
14
18
  when 403
15
- raise PaylocityWebService::Forbidden, response_values(response)
19
+ PaylocityWebService::Forbidden
16
20
  when 404
17
- raise PaylocityWebService::NotFound, response_values(response)
21
+ PaylocityWebService::NotFound
18
22
  when 405
19
- raise PaylocityWebService::MethodNotAllowed, response_values(response)
23
+ PaylocityWebService::MethodNotAllowed
20
24
  when 406
21
- raise PaylocityWebService::NotAcceptable, response_values(response)
25
+ PaylocityWebService::NotAcceptable
22
26
  when 409
23
- raise PaylocityWebService::Conflict, response_values(response)
27
+ PaylocityWebService::Conflict
24
28
  when 415
25
- raise PaylocityWebService::UnsupportedMediaType, response_values(response)
29
+ PaylocityWebService::UnsupportedMediaType
26
30
  when 422
27
- raise PaylocityWebService::UnprocessableEntity, response_values(response)
31
+ PaylocityWebService::UnprocessableEntity
28
32
  when 451
29
- raise PaylocityWebService::UnavailableForLegalReasons, response_values(response)
33
+ PaylocityWebService::UnavailableForLegalReasons
30
34
  when 400..499
31
- raise PaylocityWebService::ClientError, response_values(response)
35
+ PaylocityWebService::ClientError
32
36
  when 500
33
- raise PaylocityWebService::InternalServerError, response_values(response)
37
+ PaylocityWebService::InternalServerError
34
38
  when 501
35
- raise PaylocityWebService::NotImplemented, response_values(response)
39
+ PaylocityWebService::NotImplemented
36
40
  when 502
37
- raise PaylocityWebService::BadGateway, response_values(response)
41
+ PaylocityWebService::BadGateway
38
42
  when 503
39
- raise PaylocityWebService::ServiceUnavailable, response_values(response)
43
+ PaylocityWebService::ServiceUnavailable
40
44
  when 500..599
41
- raise PaylocityWebService::ServerError, response_values(response)
45
+ PaylocityWebService::ServerError
42
46
  end
43
- end
44
47
 
45
- private
46
-
47
- def self.response_values(response)
48
- return nil if response.nil?
49
-
50
- {
51
- status: response.status,
52
- headers: response.response_headers,
53
- body: response.body,
54
- request: {
55
- method: response.method,
56
- url_path: response.url.path,
57
- params: response.params,
58
- headers: response.request_headers,
59
- body: response.request_body
60
- }
61
- }
48
+ klass.new(response)
62
49
  end
63
50
  end
64
51
 
52
+ private
53
+
54
+ def initialize(response=nil)
55
+ @response = response
56
+ super(build_error_message)
57
+ end
58
+
59
+ def build_error_message
60
+ return nil if response.nil?
61
+
62
+ message = "Status: #{response&.status} \n"
63
+ message << "Method: #{response&.method&.to_s.upcase} \n"
64
+ message << "URL: #{response&.url&.to_s} \n"
65
+ message << "Body: \n"
66
+ message << JSON.pretty_generate(response&.body)
67
+ message
68
+
69
+ # message = {
70
+ # status: response.status,
71
+ # headers: response.response_headers,
72
+ # body: response.body,
73
+ # request: {
74
+ # method: response.method,
75
+ # url_path: response.url.path,
76
+ # params: response.params,
77
+ # headers: response.request_headers,
78
+ # body: response.request_body
79
+ # }
80
+ # }
81
+ # JSON.pretty_generate(message)
82
+
83
+ end
84
+ end
85
+
65
86
  # Raised on errors in the 400-499 range
66
87
  class ClientError < Error; end
67
88
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaylocityWebService
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paylocity_web_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Lv
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-21 00:00:00.000000000 Z
11
+ date: 2022-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -64,6 +64,7 @@ files:
64
64
  - lib/paylocity_web_service/client/companies.rb
65
65
  - lib/paylocity_web_service/client/credentials.rb
66
66
  - lib/paylocity_web_service/client/employees.rb
67
+ - lib/paylocity_web_service/client/onboardings.rb
67
68
  - lib/paylocity_web_service/configuration.rb
68
69
  - lib/paylocity_web_service/connection.rb
69
70
  - lib/paylocity_web_service/encryption.rb