hubspot-ruby 0.6.1 → 0.7.0

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: 2bf3e6e8fbd83defe0525c7d692eb797d2650eeb6919ffdc5c55505345da233e
4
- data.tar.gz: 7880ed3f94d9ce4784668a20eb254635e72484e2d0dfba9cb2b988cfc5846756
3
+ metadata.gz: b7ccc908caacf0397188a0feed3bc1475d35123af86e79f5030bdf77e28353cf
4
+ data.tar.gz: 29f5fd9a6852e3478e6c893bfdb33450d124dad8b6b5a64aa125f2218d8522bc
5
5
  SHA512:
6
- metadata.gz: 14385b0ece499e0092dd3de5de1de3b6fcb89c5acc90407a597c0a06658489302e9f7199def1ccb4dc58c118371fe4481e142060ad319c52cee99f55d4bf16ea
7
- data.tar.gz: ce08579ea8415650d1599fff9cc31e6c14da1bbd90eea8974a9ef16c961b803de838bd0d5fd8a97e559140ce0b9e21cdf0b6fd3bb0769e09402272a5227799ac
6
+ metadata.gz: 3ea051ba6010fc36d8af599cee489690beb08c605b91a4b371ed14800098d40eefcb7cd9268e9e5c1944cb8866defd3798300bc5600861360e0b44eb8c977c1b
7
+ data.tar.gz: d151b777a26d072b15cf721e01460787ed141fda91af3322dc6d5034c5139c88eb9d55316fbc0d9f727f149e7374b43da936ac373a8e3033d829c1cebd18b6d6
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "hubspot-ruby"
3
- s.version = "0.6.1"
3
+ s.version = "0.7.0"
4
4
  s.require_paths = ["lib"]
5
5
  s.authors = ["Andrew DiMichele", "Chris Bisnett"]
6
6
  s.description = "hubspot-ruby is a wrapper for the HubSpot REST API"
@@ -10,6 +10,9 @@ Gem::Specification.new do |s|
10
10
  s.files += Dir["spec/**/*.rb"]
11
11
  s.homepage = "http://github.com/adimichele/hubspot-ruby"
12
12
  s.summary = "hubspot-ruby is a wrapper for the HubSpot REST API"
13
+ s.metadata = {
14
+ "changelog_uri" => "https://github.com/adimichele/hubspot-ruby/blob/master/History.md"
15
+ }
13
16
 
14
17
  # Add runtime dependencies here
15
18
  s.add_runtime_dependency "activesupport", ">=3.0.0"
@@ -6,7 +6,7 @@ module Hubspot
6
6
 
7
7
  CONFIG_KEYS = [
8
8
  :hapikey, :base_url, :portal_id, :logger, :access_token, :client_id,
9
- :client_secret, :redirect_uri
9
+ :client_secret, :redirect_uri, :read_timeout, :open_timeout
10
10
  ]
11
11
  DEFAULT_LOGGER = Logger.new(nil)
12
12
 
@@ -23,6 +23,8 @@ module Hubspot
23
23
  @client_id = config["client_id"] if config["client_id"].present?
24
24
  @client_secret = config["client_secret"] if config["client_secret"].present?
25
25
  @redirect_uri = config["redirect_uri"] if config["redirect_uri"].present?
26
+ @read_timeout = config['read_timeout'] || config['timeout']
27
+ @open_timeout = config['open_timeout'] || config['timeout']
26
28
 
27
29
  unless access_token.present? ^ hapikey.present?
28
30
  Hubspot::ConfigurationError.new("You must provide either an access_token or an hapikey")
@@ -5,7 +5,7 @@ module Hubspot
5
5
  class << self
6
6
  def get_json(path, opts)
7
7
  url = generate_url(path, opts)
8
- response = get(url, format: :json)
8
+ response = get(url, format: :json, read_timeout: read_timeout(opts), open_timeout: open_timeout(opts))
9
9
  log_request_and_response url, response
10
10
  raise(Hubspot::RequestError.new(response)) unless response.success?
11
11
  response.parsed_response
@@ -15,24 +15,32 @@ module Hubspot
15
15
  no_parse = opts[:params].delete(:no_parse) { false }
16
16
 
17
17
  url = generate_url(path, opts[:params])
18
- response = post(url, body: opts[:body].to_json, headers: { 'Content-Type' => 'application/json' }, format: :json)
18
+ response = post(url, { body: opts[:body].to_json, headers: { 'Content-Type' => 'application/json' }, format: :json, read_timeout: read_timeout(opts), open_timeout: open_timeout(opts) })
19
19
  log_request_and_response url, response, opts[:body]
20
20
  raise(Hubspot::RequestError.new(response)) unless response.success?
21
21
 
22
22
  no_parse ? response : response.parsed_response
23
23
  end
24
24
 
25
- def put_json(path, opts)
26
- url = generate_url(path, opts[:params])
27
- response = put(url, body: opts[:body].to_json, headers: { 'Content-Type' => 'application/json' }, format: :json)
28
- log_request_and_response url, response, opts[:body]
29
- raise(Hubspot::RequestError.new(response)) unless response.success?
30
- response.parsed_response
25
+ def put_json(path, options)
26
+ url = generate_url(path, options[:params])
27
+
28
+ response = put(
29
+ url,
30
+ body: options[:body].to_json,
31
+ headers: { "Content-Type" => "application/json" },
32
+ format: :json,
33
+ read_timeout: read_timeout(options),
34
+ open_timeout: open_timeout(options),
35
+ )
36
+
37
+ log_request_and_response(url, response, options[:body])
38
+ handle_response(response)
31
39
  end
32
40
 
33
41
  def delete_json(path, opts)
34
42
  url = generate_url(path, opts)
35
- response = delete(url, format: :json)
43
+ response = delete(url, format: :json, read_timeout: read_timeout(opts), open_timeout: open_timeout(opts))
36
44
  log_request_and_response url, response, opts[:body]
37
45
  raise(Hubspot::RequestError.new(response)) unless response.success?
38
46
  response
@@ -40,6 +48,22 @@ module Hubspot
40
48
 
41
49
  protected
42
50
 
51
+ def read_timeout(opts = {})
52
+ opts.delete(:read_timeout) || Hubspot::Config.read_timeout
53
+ end
54
+
55
+ def open_timeout(opts = {})
56
+ opts.delete(:open_timeout) || Hubspot::Config.open_timeout
57
+ end
58
+
59
+ def handle_response(response)
60
+ if response.success?
61
+ response.parsed_response
62
+ else
63
+ raise(Hubspot::RequestError.new(response))
64
+ end
65
+ end
66
+
43
67
  def log_request_and_response(uri, response, body=nil)
44
68
  Hubspot::Config.logger.info "Hubspot: #{uri}.\nBody: #{body}.\nResponse: #{response.code} #{response.body}"
45
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubspot-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew DiMichele
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-11-29 00:00:00.000000000 Z
12
+ date: 2019-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -260,7 +260,8 @@ files:
260
260
  - spec/support/vcr.rb
261
261
  homepage: http://github.com/adimichele/hubspot-ruby
262
262
  licenses: []
263
- metadata: {}
263
+ metadata:
264
+ changelog_uri: https://github.com/adimichele/hubspot-ruby/blob/master/History.md
264
265
  post_install_message:
265
266
  rdoc_options: []
266
267
  require_paths: