crystal_sdk 1.1.1 → 1.2.1

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: 3fba72cd5d68a944a3591b68616c2870f24e5911
4
- data.tar.gz: 3c6a8fe33e641fc48110bfaf029be485413ab29b
3
+ metadata.gz: 2693afc6e01dbd3701555cbb51711ea7c0feebd2
4
+ data.tar.gz: 869ad50b056891ca6ec29e2efae55f7b65ef0605
5
5
  SHA512:
6
- metadata.gz: 81b04211837990b86b3e5e541e829098485504b9fd1804ec47e637cb33c2a4ece1b211c7b92004f082b8f982f50e1549ffa53d12bb63275f6e4435489b281600
7
- data.tar.gz: 18b848e785fc232916f9bf7cdc3736b5a07e2f98665309f3410abacfab74044134937e5c23cec32e341b70d35f555f2df2c3aad7759ceffd870b36c4d6882ea9
6
+ metadata.gz: 89eeb6aa8e32af5e7caa3275b914381704644a89d5bb674db1090c6b2093b11c6a651f2ee083a4ecc875e195bc0f3ed9361fd09435961b4fa5344fe1508e9d4a
7
+ data.tar.gz: 655aec7b9b3f79e7f9c251a5789332dc2a140866f3b4a10f42d27e7a4f8af513f3a67bc2861a84caa9778c0da733563662da6607afc4feb85c803a0a6a6bd2ec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crystal_sdk (1.0.3)
4
+ crystal_sdk (1.1.1)
5
5
  nestful (~> 1.1)
6
6
  recursive-open-struct (~> 1.0)
7
7
 
@@ -16,7 +16,7 @@ GEM
16
16
  hashdiff (0.3.2)
17
17
  nestful (1.1.1)
18
18
  public_suffix (2.0.5)
19
- recursive-open-struct (1.0.2)
19
+ recursive-open-struct (1.0.4)
20
20
  rspec (3.5.0)
21
21
  rspec-core (~> 3.5.0)
22
22
  rspec-expectations (~> 3.5.0)
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  This gem provides access to Crystal, the world's largest and most accurate personality database!
7
7
 
8
+
8
9
  ![API Summary](docs/api_summary.gif)
9
10
 
10
11
  ## FAQ
data/lib/crystal_sdk.rb CHANGED
@@ -5,6 +5,7 @@ module CrystalSDK
5
5
  autoload :Base, 'crystal_sdk/base'
6
6
  autoload :Api, 'crystal_sdk/api'
7
7
  autoload :Profile, 'crystal_sdk/profile'
8
+ autoload :EmailSample, 'crystal_sdk/email_sample'
8
9
 
9
10
  crystal_env_key = ENV['CRYSTAL_KEY']
10
11
  CrystalSDK.key = crystal_env_key if crystal_env_key
@@ -0,0 +1,18 @@
1
+ require 'timeout'
2
+ require_relative 'email_sample/errors'
3
+ require_relative 'email_sample/request'
4
+
5
+ module CrystalSDK
6
+ class EmailSample
7
+
8
+ def initialize()
9
+ end
10
+
11
+ class << self
12
+ def all(request_id)
13
+ sample = EmailSample::Request.new(request_id)
14
+ sample.from_all
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module CrystalSDK
2
+ class EmailSample
3
+ class NotFoundError < StandardError; end
4
+ class UnexpectedError < StandardError; end
5
+
6
+ class NotAuthedError < StandardError
7
+ attr_reader :token
8
+
9
+ def initialize(token, msg = 'Organization Token was invalid')
10
+ @token = token
11
+ super(msg)
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ require 'recursive-open-struct'
2
+ require 'crystal_sdk/api'
3
+
4
+ module CrystalSDK
5
+ class EmailSample
6
+ class Request
7
+
8
+ def initialize(id)
9
+ @id = id
10
+ end
11
+
12
+ def from_all
13
+ begin
14
+ resp = Api.make_request(:get, "emails/#{@id}")
15
+ rescue Nestful::ResponseError => e
16
+ check_for_error(e.response)
17
+ raise e
18
+ end
19
+
20
+ body = JSON.parse(resp.body || '{}', symbolize_names: true)
21
+ end
22
+
23
+ def check_for_error(resp)
24
+ raise EmailSample::NotAuthedError.new(Base.key) if resp.code == '401'
25
+ raise EmailSample::NotFoundError if resp.code == '404'
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module CrystalSDK
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.2.1'.freeze
3
3
  end
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.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cory Finger
@@ -86,6 +86,9 @@ files:
86
86
  - lib/crystal_sdk.rb
87
87
  - lib/crystal_sdk/api.rb
88
88
  - lib/crystal_sdk/base.rb
89
+ - lib/crystal_sdk/email_sample.rb
90
+ - lib/crystal_sdk/email_sample/errors.rb
91
+ - lib/crystal_sdk/email_sample/request.rb
89
92
  - lib/crystal_sdk/profile.rb
90
93
  - lib/crystal_sdk/profile/errors.rb
91
94
  - lib/crystal_sdk/profile/request.rb
@@ -117,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
120
  version: '0'
118
121
  requirements: []
119
122
  rubyforge_project:
120
- rubygems_version: 2.6.8
123
+ rubygems_version: 2.6.6
121
124
  signing_key:
122
125
  specification_version: 4
123
126
  summary: Access the largest and most accurate personality database!