File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55/coverage /
66/doc /
77/pkg /
8+ /lib /debugger.rb
89/spec /reports /
910/tmp /
11+ .env
Original file line number Diff line number Diff line change @@ -30,12 +30,13 @@ Gem::Specification.new do |spec|
3030 spec . executables = spec . files . grep ( %r{^exe/} ) { |f | File . basename ( f ) }
3131 spec . require_paths = [ "lib" ]
3232
33- spec . add_dependency 'http ' , '~> 2.1 '
33+ spec . add_dependency 'typhoeus ' , '~> 1.1' , '>= 1.1.2 '
3434 spec . add_dependency 'multi_json' , '~> 1.12' , '>= 1.12.1'
3535
3636 spec . add_development_dependency 'bundler' , '~> 1.13' , '>= 1.13.6'
3737 spec . add_development_dependency 'rake' , '~> 12.0'
3838 spec . add_development_dependency 'rspec' , '~> 3.5'
3939 spec . add_development_dependency 'vcr' , '~> 3.0' , '>= 3.0.3'
4040 spec . add_development_dependency 'webmock' , '~> 2.3' , '>= 2.3.1'
41+ spec . add_development_dependency 'dotenv' , '~> 2.1' , '>= 2.1.1'
4142end
Original file line number Diff line number Diff line change 1+ $LOAD_PATH. unshift File . expand_path ( "../../lib" , __FILE__ )
2+
13require "contentstack/version"
24require "contentstack/client"
35
4-
56module Contentstack
6- # The client object is initialized with a space and a key and then used
7+ # The client object is initialized with an api_key and an access_token and then used
78 # for querying resources from this space.
89 # See README for details
910end
11+
12+ # require 'debugger'
Original file line number Diff line number Diff line change 1+ module Contentstack
2+ # All errors raised by the Contentstack gem are either instances of Contentstack::Error
3+ # or inherit from Contentstack::Error
4+ class Error < StandardError
5+ attr_reader :response
6+
7+ def initialize ( response )
8+ @response = response
9+ super @response . error_message
10+ end
11+
12+ # Shortcut for creating specialized error classes
13+ # USAGE rescue Contentstack::Error[404]
14+ def self . []( error_status_code )
15+ case error_status_code
16+ when 404
17+ NotFound
18+ when 400
19+ BadRequest
20+ when 403
21+ AccessDenied
22+ when 401
23+ Unauthorized
24+ when 429
25+ RateLimitExceeded
26+ when 500
27+ ServerError
28+ when 503
29+ ServiceUnavailable
30+ else
31+ Error
32+ end
33+ end
34+ end
35+
36+ # 404
37+ class NotFound < Error ; end
38+
39+ # 400
40+ class BadRequest < Error ; end
41+
42+ # 403
43+ class AccessDenied < Error ; end
44+
45+ # 401
46+ class Unauthorized < Error ; end
47+
48+ # 429
49+ class RateLimitExceeded < Error ; end
50+
51+ # 500
52+ class ServerError < Error ; end
53+
54+ # 503
55+ class ServiceUnavailable < Error ; end
56+
57+ # Raised when response is no valid json
58+ class UnparsableJson < Error ; end
59+
60+ # Raised when response is not parsable as a Contentstack::Resource
61+ class UnparsableResource < Error ; end
62+ end
Original file line number Diff line number Diff line change 1+
2+ module Contentstack
3+
4+ class Response
5+ attr_reader :body
6+
7+ def initialize ( body )
8+ @body = body
9+ end
10+
11+ def entries
12+ @body [ :entries ]
13+ end
14+ end
15+
16+ end
You can’t perform that action at this time.
0 commit comments