zoho_crm 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb7d7d7ebaebee1c6b695fff83448f0c55479e78
4
- data.tar.gz: 99117e2d42fcfc09eece826582528c08b698723b
3
+ metadata.gz: e2013e2d034f5dca54e51a98fdb96ac579beb0fe
4
+ data.tar.gz: 3bbd6cd32160f0483c3d838ea3c5f0d92298cc5c
5
5
  SHA512:
6
- metadata.gz: 2c4e599a1beda9c0d90c9dedbfe5a7465e7965636fc9d26f8b97bca32e15b03ad0c8434bc66c8391c376b60b1e090162d742b8f1794439ec47d6149833f86f2c
7
- data.tar.gz: e2e1abf0895c544b4e203a7ec63b32c7c532439e797542f53959edf42eaba11497a34b3727fa51fa1b4d2b2b6c7ab031031f2ffbc2f13f338c6ae1c6258b700e
6
+ metadata.gz: 2c012c753753bdd0cbcf8c57f3936a0a553cac5ca3c1e211c4f86ec7d985de87fb4d691007bedae2849f00a2fb8b262b4e9b6e734152a1ce1f40a9df4e08007e
7
+ data.tar.gz: dd42ad0fdf96506d8927110e23af8756e58e5c8414cc71573e2dbe3c73af2a65b198e54e7abe473106ab9eb76e472e5e690b96e810d9ff95c6a2c88ea929e865
@@ -1,5 +1,5 @@
1
1
  module ZohoCrm
2
2
  class Client
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
data/lib/zoho_crm.rb CHANGED
@@ -3,6 +3,14 @@ require 'httparty'
3
3
 
4
4
  module ZohoCrm
5
5
  RateLimitExceeded = Class.new(StandardError)
6
+
7
+ class AuthenticationFailure < StandardError
8
+ attr_reader :message
9
+ def initialize(message)
10
+ @message = message
11
+ end
12
+ end
13
+
6
14
  class Client
7
15
 
8
16
  AUTH_URL = "https://accounts.zoho.com/apiauthtoken/nb/create?SCOPE=ZohoCRM/crmapi&"
@@ -30,7 +38,7 @@ module ZohoCrm
30
38
  response = HTTParty.post(token_url)
31
39
  response_body = response.body
32
40
  auth_info = Hash[response_body.split(" ").map { |str| str.split("=") }]
33
- auth_info["AUTHTOKEN"]
41
+ raise_auth_exception(auth_info["AUTHTOKEN"])
34
42
  end
35
43
 
36
44
  def retrieve_contacts(auth_token, from_index, to_index)
@@ -192,5 +200,13 @@ module ZohoCrm
192
200
  end
193
201
  end
194
202
 
203
+ def raise_auth_exception(token)
204
+ if token.nil?
205
+ raise AuthenticationFailure.new("Good gracious! Incorrect credentials or too many active auth tokens")
206
+ else
207
+ token
208
+ end
209
+ end
210
+
195
211
  end
196
212
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoho_crm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ciaran Lofts
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-17 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty