paylocity_web_service 0.1.0 → 0.1.2

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: 785d1989802a97490574f7527a260c0c3e3a1d598301421cc74630525cc4f0a4
4
+ data.tar.gz: f1323abd22825eacf39dc03c3f1abc20ef2994f89b811f3295a73f2b0f5d936b
5
5
  SHA512:
6
- metadata.gz: b31b8fee32111c963201c92c7404544a6baf3efd73d21bb3fba04faaa1570b411db3c95d99ef3f288e63e8968360c991216791ef9b11bae47d46ac092d24397e
7
- data.tar.gz: 3074459e1e51a24a12b48b7835fcf4a5301f3a7b324101ff45639f70a86a0016cc45c315efbcf06fce33f7ce378f5d638b0db6db0d25da22ca8ff72c30b2e4d0
6
+ metadata.gz: 7b0d6ed1aa48cbf529597a210c519916b2b2b44f38c0f82848909c404fef3cf4d6fee9aa0f5fe33779c2a499fd7d820a80906e112187a24d6d9736a543266a12
7
+ data.tar.gz: 94882dbd2970de70dd7552ccc133f0ca03e8bc2d43d2be95e845dbec2796e25a136281599265ec313f1ec4927c2e592ba5b29dd72a81166ef3deca11b0e19c6f
@@ -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
@@ -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
@@ -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.1.2"
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.1.2
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: 2021-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday