oanda_api_v20 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: 878d9236c1b27b3002837bd54861020d3b64ea48
4
- data.tar.gz: 78d7ed60b12898c1e3f67e6c82796578cef72d66
3
+ metadata.gz: df006567cbd1acee31c44649ff9660bae3cbd8ca
4
+ data.tar.gz: cbc54442151b3a3cb06fd4044812a56fc23ed52a
5
5
  SHA512:
6
- metadata.gz: 62351ec69ce656e9c5c270a598eef8acc4eee888eb1439b5462b8daeee1f6a2d9c0debf848cac9bf46ea03f9a5273ababe7caf132f8f89b2d64109d3fc86778e
7
- data.tar.gz: 66788082097a9fb23eb5c85874f3cb6af721fc2317268cd3a301a96b248649dcd7c6be6d52b71914f0d57f3ac3ae6f2c91f6624d571c1c9a2e05eaff241c2e6d
6
+ metadata.gz: fc14f293e67e1b0351044dd1f50621d248b633c9d254ae9a4f0d5a6bff990b381560370c497409117a01f1da1524b077afb30453b4e6f492087f3677a6b32d09
7
+ data.tar.gz: 5c82460ae6765964e0f23d93d4b6176d848cb6fce9a07d143371c1e132329d631a2a76f4102022b5a26f052b5259c675fad98abeb1fd3bfb94c6475d7b85e600
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.6
4
+ #### 2016-08-18
5
+ * HTTP exception handling added.
6
+
3
7
  ## 0.0.5
4
8
  #### 2016-08-16
5
9
  * Added the Gemfile to allow the 'bundle install' command to work.
data/README.md CHANGED
@@ -252,6 +252,10 @@ options = {
252
252
  client.account('account_id').pricing(options).show
253
253
  ```
254
254
 
255
+ ## Exceptions
256
+
257
+ A `OandaApiV20::RequestError` will be raised when a request to the Oanda API failed for any reason.
258
+
255
259
  ## Contributing
256
260
 
257
261
  1. Fork it
data/lib/oanda_api_v20.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'httparty'
2
2
  require 'persistent_httparty'
3
+ require 'http/exceptions'
3
4
 
4
5
  require 'oanda_api_v20/version'
6
+ require 'oanda_api_v20/exceptions'
5
7
  require 'oanda_api_v20/accounts'
6
8
  require 'oanda_api_v20/orders'
7
9
  require 'oanda_api_v20/trades'
@@ -46,7 +46,15 @@ module OandaApiV20
46
46
  if api.respond_to?(last_action)
47
47
  set_last_api_request_at
48
48
  govern_api_request_rate
49
- response = last_arguments.nil? || last_arguments.empty? ? api.send(last_action, &block) : api.send(last_action, *last_arguments, &block)
49
+
50
+ begin
51
+ response = Http::Exceptions.wrap_exception do
52
+ last_arguments.nil? || last_arguments.empty? ? api.send(last_action, &block) : api.send(last_action, *last_arguments, &block)
53
+ end
54
+ rescue Http::Exceptions::HttpException => e
55
+ raise OandaApiV20::RequestError, e.message
56
+ end
57
+
50
58
  api_result = JSON.parse(response.body)
51
59
  set_last_transaction_id(api_result)
52
60
  end
@@ -0,0 +1,3 @@
1
+ module OandaApiV20
2
+ class RequestError < RuntimeError; end
3
+ end
@@ -1,3 +1,3 @@
1
1
  module OandaApiV20
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_dependency 'httparty', '~> 0.13'
20
20
  s.add_dependency 'persistent_httparty', '~> 0.1'
21
+ s.add_dependency 'http-exceptions', '~> 0.1'
21
22
 
22
23
  s.files = `git ls-files`.split("\n")
23
24
  s.require_paths = ['lib']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oanda_api_v20
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kobus Joubert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-16 00:00:00.000000000 Z
11
+ date: 2016-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: http-exceptions
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.1'
41
55
  description: Ruby client that supports the Oanda REST API V20 methods.
42
56
  email: kobus@translate3d.com
43
57
  executables: []
@@ -53,6 +67,7 @@ files:
53
67
  - lib/oanda_api_v20/accounts.rb
54
68
  - lib/oanda_api_v20/api.rb
55
69
  - lib/oanda_api_v20/client.rb
70
+ - lib/oanda_api_v20/exceptions.rb
56
71
  - lib/oanda_api_v20/oanda_api_v20.rb
57
72
  - lib/oanda_api_v20/orders.rb
58
73
  - lib/oanda_api_v20/positions.rb