crystal_sdk 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: ed49b547a11579d80d9aa3c96dab61019d0dd47b
4
- data.tar.gz: 49afdf1d21487a6d4def81f564feb3eec54dfc54
3
+ metadata.gz: 0ac7754e0ca7737a3f792fbf72b1a38fc333db61
4
+ data.tar.gz: 36981f0bda19928584e1c408afdd0e52faf329ae
5
5
  SHA512:
6
- metadata.gz: 55a5a0ca2e44a4df1cf4b3455703da564ffc32a39fd22e2d020c5c2a05ab9ef8b7f89e0f0559c371e64ae84bb2b5f5270ac5043efed0ea92ec7a05703519e68d
7
- data.tar.gz: 13a84fc643b862bde2f5f3a7f7cf8cd3cf292379233d23e13324ba1a05c76ec00f919fe0b4d01a94e57bd4d8914abf1ce745b226de9d5652be19bcc5c4e2a8e7
6
+ metadata.gz: c4bffe97b1b4cc64e5f76b5e25e15032b58636b96bbb44d102e960dd349c8d351580d4a6485530b0a2fb13875ad1e901a188a2f876c1ca123fdbf78aaeb0104a
7
+ data.tar.gz: 6c6579a048f4c7ba398514e52507eaa98a71ff9137e5a3608255df83f5ddd3e36c1b6dc1ca6d01516a3684eaab31b6d794c78b521d6801ec3ab1e0b2d84195d3
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .DS_Store
1
2
  *.gem
2
3
  *.rbc
3
4
  /.config
data/README.md CHANGED
@@ -17,7 +17,12 @@ CrystalSDK.key = "OrgKey"
17
17
  begin
18
18
  profile = CrystalSDK::Profile.search({
19
19
  first_name: "Drew",
20
- last_name: "D'Agostino"
20
+ last_name: "D'Agostino",
21
+ email: "drew@crystalknows.com",
22
+ company_name: "Crystal",
23
+ location: "Nashville, TN",
24
+ text_sample: "I, Drew, the founder of Crystal, think that ...",
25
+ text_type: "various"
21
26
  })
22
27
 
23
28
  print "Profile found!"
@@ -29,17 +34,17 @@ begin
29
34
 
30
35
  print "Recommendations: #{profile.recommendations}"
31
36
 
32
- rescue CrystalSDK::Profile::NotFoundError
37
+ rescue CrystalSDK::Profile::NotFoundError => e
33
38
  print "No profile was found"
34
39
 
35
- rescue CrystalSDK::Profile::NotFoundYetError
36
- print "Profile search exceeded time limit"
40
+ rescue CrystalSDK::Profile::NotFoundYetError => e
41
+ print "Profile search exceeded time limit: #{e.request.id}"
37
42
 
38
- rescue CrystalSDK::Profile::RateLimitHitError
43
+ rescue CrystalSDK::Profile::RateLimitHitError => e
39
44
  print "The organization's API rate limit was hit"
40
45
 
41
- rescue CrystalSDK::Profile::NotAuthedError
42
- print "Org key was invalid"
46
+ rescue CrystalSDK::Profile::NotAuthedError => e
47
+ print "Org key was invalid: #{e.token}"
43
48
 
44
49
  rescue StandardError => e
45
50
  print "Unexpected error occurred: #{e}"
@@ -4,10 +4,18 @@ require_relative 'profile/request'
4
4
  module CrystalSDK
5
5
  class Profile
6
6
  class NotFoundError < StandardError; end
7
- class NotAuthedError < StandardError; end
8
7
  class RateLimitHitError < StandardError; end
9
8
  class UnexpectedError < StandardError; end
10
9
 
10
+ class NotAuthedError < StandardError
11
+ attr_reader :token
12
+
13
+ def initialize(token, msg = 'Organization Token was invalid')
14
+ @token = token
15
+ super(msg)
16
+ end
17
+ end
18
+
11
19
  class NotFoundYetError < StandardError
12
20
  attr_reader :request
13
21
 
@@ -57,7 +65,7 @@ module CrystalSDK
57
65
 
58
66
  def check_for_error(resp)
59
67
  raise RateLimitHitError if resp.code == '429'
60
- raise NotAuthedError if resp.code == '401'
68
+ raise NotAuthedError.new(Base.key) if resp.code == '401'
61
69
  raise NotFoundError if resp.code == '404'
62
70
  end
63
71
  end
@@ -1,3 +1,3 @@
1
1
  module CrystalSDK
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
@@ -92,6 +92,12 @@ describe CrystalSDK::Profile do
92
92
 
93
93
  it 'should raise NotFoundYetError' do
94
94
  expect { subject }.to raise_error(CrystalSDK::Profile::NotFoundYetError)
95
+
96
+ begin
97
+ subject
98
+ rescue CrystalSDK::Profile::NotFoundYetError => e
99
+ expect(e.request).to be(response)
100
+ end
95
101
  end
96
102
  end
97
103
  end
@@ -120,8 +126,23 @@ describe CrystalSDK::Profile do
120
126
  context '401' do
121
127
  let(:resp) { double(code: '401') }
122
128
 
129
+ before(:each) do
130
+ @orig_key = CrystalSDK.key
131
+ CrystalSDK.key = 'SomeKey'
132
+ end
133
+
134
+ after(:each) do
135
+ CrystalSDK.key = @orig_key
136
+ end
137
+
123
138
  it 'should raise NotAuthedError' do
124
139
  expect { subject }.to raise_error(CrystalSDK::Profile::NotAuthedError)
140
+
141
+ begin
142
+ subject
143
+ rescue CrystalSDK::Profile::NotAuthedError => e
144
+ expect(e.token).to eql('SomeKey')
145
+ end
125
146
  end
126
147
  end
127
148
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crystal_sdk
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
  - Cory Finger