yotpo 1.0.4 → 1.0.5

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
  SHA256:
3
- metadata.gz: 30a4afe6dcf9fd106b06eafcf3e1993b2670c3b4d63a781263a45bd3b00191cf
4
- data.tar.gz: af933d50164d18c60c77fc4b5da2426588a88c40ece2275e135cb8679430c22f
3
+ metadata.gz: 19ec639260657da67005f8aab271b0db691880fec072713f32c91fa1b1de1e79
4
+ data.tar.gz: feee72358ccf03f52a6d23688737d96a83b684f283417d7808b831f71694145e
5
5
  SHA512:
6
- metadata.gz: e6a2d157834a1ec93cb93aba761548e373931d5e2b9c551c3e3ead1c1d26b8a93f4a5aff41c0d50f3ab318db2b0dae97ecec199171ede97fd04aea7b81897de6
7
- data.tar.gz: c6e7bf290fd8594f3fe37ce9a77ea30e56a2f8defef30fa0430b0792b812b10d8f713be3d5fa07090b1f690df3e1d5b9358669947fd84f4e5b69d2e2092b6397
6
+ metadata.gz: 4d3cca8d9db338aec54be8e5a3394356424562a0f51d3bbc1968634e315d394884f78ac792dbe2482f8336c487f8383cd917208cea254d8b487a9a82591bc2dc
7
+ data.tar.gz: 081805d8331568f0caca62a570aa1ce0f132cc787105b92ba2e78f8d5fb7cc6dc7f99dafe05aa72f80eec5a983f9d367200ee672743371edfe4d715103212fb0
@@ -19,6 +19,14 @@ module Yotpo
19
19
  # @return [String] the secret that is registered with Yotpo
20
20
  attr_accessor :secret
21
21
 
22
+ # @!attribute timeout
23
+ # @return [int] connection timeout in seconds
24
+ attr_accessor :timeout
25
+
26
+ # @!attribute user_agent
27
+ # @return [string] global user agent in header
28
+ attr_accessor :user_agent
29
+
22
30
  # Configuration interface of the gem
23
31
  #
24
32
  # @yield [self] to accept configuration settings
@@ -40,7 +48,7 @@ module Yotpo
40
48
  # @return an instance of Yotpo::Client
41
49
  #
42
50
  def client
43
- @client ||= Yotpo::Client.new(@url || 'https://api.yotpo.com')
51
+ @client ||= Yotpo::Client.new(@url || 'https://api.yotpo.com', @parallel_requests || 5, @timeout || 60, @user_agent)
44
52
  end
45
53
 
46
54
  private
@@ -38,6 +38,8 @@ module Yotpo
38
38
  '/users'
39
39
  elsif owner_type == :account
40
40
  '/apps'
41
+ elsif owner_type == :organization
42
+ '/organizations'
41
43
  else
42
44
  raise 'Wrong owner type!'
43
45
  end
@@ -47,9 +47,12 @@ module Yotpo
47
47
  #
48
48
  # @param url [String] The url to yotpo api (https://api.yotpo.com)
49
49
  # @param parallel_requests [Integer String] The maximum parallel request to do (5)
50
- def initialize(url = 'https://api.yotpo.com', parallel_requests = 5)
50
+ def initialize(url = 'https://api.yotpo.com', parallel_requests, timeout, user_agent)
51
51
  @url = url
52
52
  @parallel_requests = parallel_requests
53
+ @timeout = timeout
54
+ @headers = { yotpo_api_connector: 'Ruby'+Yotpo::VERSION }
55
+ @headers.merge!(user_agent: user_agent) if user_agent
53
56
  end
54
57
 
55
58
  #
@@ -134,7 +137,9 @@ module Yotpo
134
137
  #
135
138
  # @return an instance of Faraday initialized with all that this gem needs
136
139
  def connection
137
- @connection ||= Faraday.new(url: @url, parallel_manager: Typhoeus::Hydra.new(max_concurrency: @parallel_requests), headers: {:yotpo_api_connector => 'Ruby'+Yotpo::VERSION}) do |conn|
140
+ @connection ||= Faraday.new(url: @url, parallel_manager: Typhoeus::Hydra.new(max_concurrency: @parallel_requests), headers: @headers) do |conn|
141
+
142
+ conn.options.timeout = @timeout
138
143
 
139
144
  conn.use Yotpo::ResponseParser
140
145
 
@@ -1,3 +1,3 @@
1
1
  module Yotpo
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yotpo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Shub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-18 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  version: '0'
230
230
  requirements: []
231
231
  rubyforge_project:
232
- rubygems_version: 2.7.3
232
+ rubygems_version: 2.7.7
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: A Ruby interface to the YOTPO API