shift_planning 1.0.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: 5d9d965889cdec208eaa3b63d9a0d106a2492aae
4
- data.tar.gz: 082ba58213165e24381c22e319b9f8851d142c72
3
+ metadata.gz: ca87d9153c5e9db23c2e970284df203b53bfb3be
4
+ data.tar.gz: c9dcecebb9c5b77e56e24b7fa166b0ca5b36bef4
5
5
  SHA512:
6
- metadata.gz: 7b994e218f879a8d8546291baff43c6daf40054613e206aa586391653ccb61124506e13610566745881b438acc4c03f5db5e59d437bb36f66a92d8e073fa2c35
7
- data.tar.gz: 7b7d62e28efe2f356fa95be08baa19a99ec4f45cf4c20bc0d9af36691d0e7b9afe98fb2fdbcc304b25b76ac89935a982678b8ee13ad865008b4344f6eacee099
6
+ metadata.gz: 922f34965feeb62c14e1753d5984e32038548172dc5d6e24ec0846ab2dbd6a8965215cac61b62ab92c640341d8c7bf443ed3bfd1b20affcc942015075ccd18cf
7
+ data.tar.gz: 972218116bf791697af08555903f390527d82a9bb98404f74ef40f0abfcf6fa96a0b68b3e8cce5ea39f36be216bc1a99fee41c221b077b7c97b8ab75cbd444ee
@@ -8,30 +8,30 @@ module ShiftPlanning
8
8
 
9
9
  def message_for_status(status)
10
10
  case status
11
- when "-3" then "Flagged API Key - Pemanently Banned"
12
- when "-2" then "Flagged API Key - Too Many invalid access attempts - contact us"
13
- when "-1" then "Flagged API Key - Temporarily Disabled - contact us"
14
- when "1" then "Success -"
15
- when "2" then "Invalid API key - App must be granted a valid key by ShiftPlanning"
16
- when "3" then "Invalid token key - Please re-authenticate"
17
- when "4" then "Invalid Method - No Method with that name exists in our API"
18
- when "5" then "Invalid Module - No Module with that name exists in our API"
19
- when "6" then "Invalid Action - No Action with that name exists in our API"
20
- when "7" then "Authentication Failed - You do not have permissions to access the service"
21
- when "8" then "Missing parameters - Your request is missing a required parameter"
22
- when "9" then "Invalid parameters - Your request has an invalid parameter type"
23
- when "10" then "Extra parameters - Your request has an extra/unallowed parameter type"
24
- when "12" then "Create Failed - Your CREATE request failed"
25
- when "13" then "Update Failed - Your UPDATE request failed"
26
- when "14" then "Delete Failed - Your DELETE request failed"
27
- when "15" then "Get Failed - Your GET request failed"
28
- when "20" then "Incorrect Permissions - You don't have the proper permissions to access this"
29
- when "90" then "Suspended API key - Access for your account has been suspended, please contact ShiftPlanning"
30
- when "91" then "Throttle exceeded - You have exceeded the max allowed requests. Try again later."
31
- when "98" then "Bad API Paramaters - Invalid POST request. See Manual."
32
- when "99" then "Service Offline - This service is temporarily offline. Try again later."
33
- when "100" then "Can not connect to LDAP - host or port are incorect"
34
- when "101" then "Can not connect to LDAP - username or password are incorrect"
11
+ when -3 then "Flagged API Key - Pemanently Banned"
12
+ when -2 then "Flagged API Key - Too Many invalid access attempts - contact us"
13
+ when -1 then "Flagged API Key - Temporarily Disabled - contact us"
14
+ when 1 then "Success -"
15
+ when 2 then "Invalid API key - App must be granted a valid key by ShiftPlanning"
16
+ when 3 then "Invalid token key - Please re-authenticate"
17
+ when 4 then "Invalid Method - No Method with that name exists in our API"
18
+ when 5 then "Invalid Module - No Module with that name exists in our API"
19
+ when 6 then "Invalid Action - No Action with that name exists in our API"
20
+ when 7 then "Authentication Failed - You do not have permissions to access the service"
21
+ when 8 then "Missing parameters - Your request is missing a required parameter"
22
+ when 9 then "Invalid parameters - Your request has an invalid parameter type"
23
+ when 10 then "Extra parameters - Your request has an extra/unallowed parameter type"
24
+ when 12 then "Create Failed - Your CREATE request failed"
25
+ when 13 then "Update Failed - Your UPDATE request failed"
26
+ when 14 then "Delete Failed - Your DELETE request failed"
27
+ when 15 then "Get Failed - Your GET request failed"
28
+ when 20 then "Incorrect Permissions - You don't have the proper permissions to access this"
29
+ when 90 then "Suspended API key - Access for your account has been suspended, please contact ShiftPlanning"
30
+ when 91 then "Throttle exceeded - You have exceeded the max allowed requests. Try again later."
31
+ when 98 then "Bad API Paramaters - Invalid POST request. See Manual."
32
+ when 99 then "Service Offline - This service is temporarily offline. Try again later."
33
+ when 100 then "Can not connect to LDAP - host or port are incorect"
34
+ when 101 then "Can not connect to LDAP - username or password are incorrect"
35
35
  else "Unknown status response: #{status}"
36
36
  end
37
37
  end
@@ -65,10 +65,14 @@ module ShiftPlanning
65
65
  })
66
66
  response = HTTP.with(@headers).post(@url, body)
67
67
  result = JSON.parse(response)
68
- raise ApiError.new(result) if result["status"] != "1"
68
+ raise ApiError.new(result) if is_error_response? result
69
69
  result
70
70
  end
71
71
 
72
+ def is_error_response?(response)
73
+ response["status"] != 1
74
+ end
75
+
72
76
  def body_formatter(body)
73
77
  {
74
78
  :body => "data=#{JSON.dump(body)}"
@@ -1,3 +1,3 @@
1
1
  module ShiftPlanning
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -8,30 +8,30 @@ describe 'ApiError' do
8
8
  end
9
9
 
10
10
  it "handles api status" do
11
- check("-3", "Flagged API Key - Pemanently Banned")
12
- check("-2", "Flagged API Key - Too Many invalid access attempts - contact us")
13
- check("-1", "Flagged API Key - Temporarily Disabled - contact us")
14
- check("1", "Success -")
15
- check("2", "Invalid API key - App must be granted a valid key by ShiftPlanning")
16
- check("3", "Invalid token key - Please re-authenticate")
17
- check("4", "Invalid Method - No Method with that name exists in our API")
18
- check("5", "Invalid Module - No Module with that name exists in our API")
19
- check("6", "Invalid Action - No Action with that name exists in our API")
20
- check("7", "Authentication Failed - You do not have permissions to access the service")
21
- check("8", "Missing parameters - Your request is missing a required parameter")
22
- check("9", "Invalid parameters - Your request has an invalid parameter type")
23
- check("10", "Extra parameters - Your request has an extra/unallowed parameter type")
24
- check("12", "Create Failed - Your CREATE request failed")
25
- check("13", "Update Failed - Your UPDATE request failed")
26
- check("14", "Delete Failed - Your DELETE request failed")
27
- check("15", "Get Failed - Your GET request failed")
28
- check("20", "Incorrect Permissions - You don't have the proper permissions to access this")
29
- check("90", "Suspended API key - Access for your account has been suspended, please contact ShiftPlanning")
30
- check("91", "Throttle exceeded - You have exceeded the max allowed requests. Try again later.")
31
- check("98", "Bad API Paramaters - Invalid POST request. See Manual.")
32
- check("99", "Service Offline - This service is temporarily offline. Try again later.")
33
- check("100", "Can not connect to LDAP - host or port are incorect")
34
- check("101", "Can not connect to LDAP - username or password are incorrect")
11
+ check(-3, "Flagged API Key - Pemanently Banned")
12
+ check(-2, "Flagged API Key - Too Many invalid access attempts - contact us")
13
+ check(-1, "Flagged API Key - Temporarily Disabled - contact us")
14
+ check(1, "Success -")
15
+ check(2, "Invalid API key - App must be granted a valid key by ShiftPlanning")
16
+ check(3, "Invalid token key - Please re-authenticate")
17
+ check(4, "Invalid Method - No Method with that name exists in our API")
18
+ check(5, "Invalid Module - No Module with that name exists in our API")
19
+ check(6, "Invalid Action - No Action with that name exists in our API")
20
+ check(7, "Authentication Failed - You do not have permissions to access the service")
21
+ check(8, "Missing parameters - Your request is missing a required parameter")
22
+ check(9, "Invalid parameters - Your request has an invalid parameter type")
23
+ check(10, "Extra parameters - Your request has an extra/unallowed parameter type")
24
+ check(12, "Create Failed - Your CREATE request failed")
25
+ check(13, "Update Failed - Your UPDATE request failed")
26
+ check(14, "Delete Failed - Your DELETE request failed")
27
+ check(15, "Get Failed - Your GET request failed")
28
+ check(20, "Incorrect Permissions - You don't have the proper permissions to access this")
29
+ check(90, "Suspended API key - Access for your account has been suspended, please contact ShiftPlanning")
30
+ check(91, "Throttle exceeded - You have exceeded the max allowed requests. Try again later.")
31
+ check(98, "Bad API Paramaters - Invalid POST request. See Manual.")
32
+ check(99, "Service Offline - This service is temporarily offline. Try again later.")
33
+ check(100, "Can not connect to LDAP - host or port are incorect")
34
+ check(101, "Can not connect to LDAP - username or password are incorrect")
35
35
  end
36
36
  end
37
37
  end
@@ -46,7 +46,7 @@ describe 'Client' do
46
46
  it 'authenticates and makes api request' do
47
47
  stub_request(:post, "http://www.shiftplanning.com/api/")
48
48
  .with(:body => {"data"=>"{\"token\":\"1714d482a0f3a5e3472fb51c481dc571fd6724e1\",\"method\":\"GET\",\"module\":\"staff.employee\",\"request\":{\"id\":1}}"}, :headers => {'Content-Type'=>'application/x-www-form-urlencoded', 'Host'=>'www.shiftplanning.com', 'User-Agent'=>'RubyHTTPGem/0.5.0'})
49
- .to_return(:status => 200, :body => "{\"status\":\"1\", \"id\":\"1\"}", :headers => {})
49
+ .to_return(:status => 200, :body => "{\"status\":1, \"id\":\"1\"}", :headers => {})
50
50
  employee = @client.get('staff.employee', "id" => 1)
51
51
  assert 1, employee[:id]
52
52
  end
@@ -56,7 +56,7 @@ describe 'Client' do
56
56
  it 'authenticates and makes api request' do
57
57
  stub_request(:post, "http://www.shiftplanning.com/api/")
58
58
  .with(:body => {"data"=>"{\"token\":\"1714d482a0f3a5e3472fb51c481dc571fd6724e1\",\"method\":\"UPDATE\",\"module\":\"staff.employee\",\"request\":{\"id\":1,\"addskill\":2}}"}, :headers => {'Content-Type'=>'application/x-www-form-urlencoded', 'Host'=>'www.shiftplanning.com', 'User-Agent'=>'RubyHTTPGem/0.5.0'})
59
- .to_return(:status => 200, :body => "{\"status\":\"1\", \"id\":\"1\"}", :headers => {})
59
+ .to_return(:status => 200, :body => "{\"status\":1, \"id\":\"1\"}", :headers => {})
60
60
 
61
61
  employee = @client.update('staff.employee', {
62
62
  "id" => 1,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shift_planning
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Mercier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-25 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http