blurb 0.4.2 → 0.4.4

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
  SHA256:
3
- metadata.gz: 5caba042dfc794c48b97784204d6f8313b25dc2e6839846bd888f5d299fcee49
4
- data.tar.gz: 3e3782654082b1b14bff86e9c8fd19c40bbcd6f988545616150992d428f04e09
3
+ metadata.gz: 208217ad096230ae4cb116feb1efe8d4a0f8c9e517375ae0f6ab1a115590ab7c
4
+ data.tar.gz: 4c96990aaf4c712f7b8bfd296b02d83676cafe9559062e04cd5fef03a8cc6213
5
5
  SHA512:
6
- metadata.gz: 4db2709c64041611004b25eab833e651b5967224eff2697d57211cf1e8a18b4304a4e2dcd58dbce67e4bb604019361e302f4e7363dc3ef04205055ed9b75af24
7
- data.tar.gz: 3333f556fd100bb2dd55031a46ee88f689e3cb6f93c250b662bb1988b603e7e35e5a817909f25263fe3e30e34db8d5afa8308d420f07585f2c2fd133370b80a6
6
+ metadata.gz: 57ffa4d5db76fb62a6c0c1ce15dd74ba9d7fd88f9a2a1b307994e993934806c78c7fdc337d414fae79726b3ca200e44a163b085d5065f38f2c94c519099dd646
7
+ data.tar.gz: 43464648f13a853d55e9de629d6931c68cff1016b9caa85a60df5515cd22aa56f780afede01a6e69fb8736215900af1d93d8554e3ff705f67433a9408fc6f7a5
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "blurb"
7
- spec.version = "0.4.2"
7
+ spec.version = "0.4.4"
8
8
  spec.authors = ["dlbunker", "eamigo13"]
9
9
  spec.email = ["evan@pattern.com"]
10
10
 
@@ -0,0 +1,3 @@
1
+ class Blurb
2
+ class FailedRequest < StandardError; end
3
+ end
@@ -0,0 +1,3 @@
1
+ class Blurb
2
+ class InvalidReportRequest < StandardError; end
3
+ end
@@ -0,0 +1,3 @@
1
+ class Blurb
2
+ class RequestThrottled < StandardError; end
3
+ end
@@ -1,6 +1,9 @@
1
1
  require 'active_support/core_ext/string'
2
2
  require "rest-client"
3
3
  require "blurb/base_class"
4
+ require "blurb/errors/request_throttled"
5
+ require "blurb/errors/invalid_report_request"
6
+ require "blurb/errors/failed_request"
4
7
 
5
8
  class Blurb
6
9
  class Request < BaseClass
@@ -32,13 +35,18 @@ class Blurb
32
35
  def make_request
33
36
  begin
34
37
  resp = RestClient::Request.execute(request_config())
35
- rescue RestClient::ExceptionWithResponse => err
36
- # If this happens, then we are downloading a report from the api, so we can simply download the location
37
- if err.response.code == 307
38
- return RestClient.get(err.response.headers[:location])
38
+ rescue RestClient::TooManyRequests => err
39
+ raise RequestThrottled.new(JSON.parse(err.response.body))
40
+ rescue RestClient::TemporaryRedirect => err
41
+ return RestClient.get(err.response.headers[:location]) # If this happens, then we are downloading a report from the api, so we can simply download the location
42
+ rescue RestClient::NotAcceptable => err
43
+ if @url.include?("report")
44
+ raise InvalidReportRequest.new(JSON.parse(err.response.body))
39
45
  else
40
- return JSON.parse(err.response.body)
46
+ raise err
41
47
  end
48
+ rescue RestClient::ExceptionWithResponse => err
49
+ raise FailedRequest.new(JSON.parse(err.response.body))
42
50
  end
43
51
  resp = convert_response(resp)
44
52
  return resp
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blurb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - dlbunker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-10-11 00:00:00.000000000 Z
12
+ date: 2019-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -176,6 +176,9 @@ files:
176
176
  - lib/blurb/base_class.rb
177
177
  - lib/blurb/campaign_requests.rb
178
178
  - lib/blurb/client.rb
179
+ - lib/blurb/errors/failed_request.rb
180
+ - lib/blurb/errors/invalid_report_request.rb
181
+ - lib/blurb/errors/request_throttled.rb
179
182
  - lib/blurb/profile.rb
180
183
  - lib/blurb/report_requests.rb
181
184
  - lib/blurb/request.rb