finale 0.1.9 → 0.1.10

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: 98b36a44709d216cb6877a747bf136a4b9f40aea
4
- data.tar.gz: fc7dd2415931b9b2cc0918f02bbd6fa8e71643d0
3
+ metadata.gz: cd79cadc39533da92c33f892d3642b76bd6a1390
4
+ data.tar.gz: 50bf9314eed254f7c9ff2ac081d89921b4fa9cc9
5
5
  SHA512:
6
- metadata.gz: 13438cd8b0c458feb5bb9187623a4f7dce169fba935e29ca27f1ecb4c80b615df00f7d22fbb44b1c02b7aa41df7b7893089f76b82e4281b5b014c3c92f658ea6
7
- data.tar.gz: 8af2cbe806488e659302cb71007167c70fb4981dd5167b84f1c1173d52142abfd780e8de5b982d01b8142147875e9ebbce0a01685d818c0bf06f69c913571cca
6
+ metadata.gz: 8e4e7493d1ea43bccd6f8331a3039a1649dc71b50e1014afe3b3dd8d6f8adb68a788e3353ac702bc143b976ad66df7fad0d95a5e2d48b276caf79faa20a1a40e
7
+ data.tar.gz: 0dc03b6cd5e10fac0099129479969c65971881b0d6553e9d82a987fd5f53261e62a44ee036675dece732280d0e6dce677edcf3bedb0fa3a127c96b9610e17ef0
@@ -9,12 +9,13 @@ require_relative"shipment"
9
9
 
10
10
  module Finale
11
11
  class Client
12
- REQUEST_LIMIT = 500 # Finale API Usage: 'https://support.finaleinventory.com/hc/en-us/articles/115007830648-Getting-Started'
12
+ REQUEST_LIMIT = 100 # Finale API Usage: 'https://support.finaleinventory.com/hc/en-us/articles/115007830648-Getting-Started'
13
13
  BASE_URL = 'https://app.finaleinventory.com'
14
14
 
15
- def initialize(account)
15
+ def initialize(account: nil, throttle_mode: false)
16
16
  @cookies = nil
17
17
  @request_count = 0
18
+ @throttle_mode = throttle_mode
18
19
  @account = account
19
20
  @login_url = construct_url(:auth)
20
21
  @order_url = construct_url(:order)
@@ -92,7 +93,7 @@ module Finale
92
93
  end
93
94
 
94
95
  def request(verb: nil, url: nil, payload: nil, filter: nil)
95
- raise MaxRequests.new(REQUEST_LIMIT) if @request_count >= REQUEST_LIMIT
96
+ handle_throttling if @request_count >= REQUEST_LIMIT
96
97
  raise NotLoggedIn.new(verb: verb, url: url) unless verb == :LOGIN || !@cookies.nil?
97
98
 
98
99
  case verb
@@ -116,6 +117,16 @@ module Finale
116
117
  body = JSON.parse(response.body, symbolize_names: true)
117
118
  body
118
119
  end
120
+
121
+ def handle_throttling
122
+ @request_count = 0
123
+
124
+ if @throttle_mode
125
+ sleep 60
126
+ else
127
+ raise MaxRequests.new(REQUEST_LIMIT)
128
+ end
129
+ end
119
130
  end
120
131
  end
121
132
 
@@ -1,3 +1,3 @@
1
1
  module Finale
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Poppler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-07 00:00:00.000000000 Z
11
+ date: 2018-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json