betfair-ng 0.1.0 → 0.2.0

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: c48417f7d98fba1d9f5e7921baf1eb516f2bd694
4
- data.tar.gz: 8ae3add7897ff82188598128aef98ce3b79b1937
3
+ metadata.gz: 8107993206e732bc2b21302b0e60e5ea4d704461
4
+ data.tar.gz: 608768440ff00294f7a022d240891a5740120d87
5
5
  SHA512:
6
- metadata.gz: f20679c2a6718b30830bb94a666401f8ad7f2ef15943d5d2dd8a2a4f8711dc2a342763388a8d976a139c4c77516faab870fd6c8272a3c4125caffa42d42fcf59
7
- data.tar.gz: 9695f1eada33d762ace02ae1e3060265b6b66806249dcab1462428f3bd56fefa4cb42570e3f5511e50650b25360b1e71847bfd138493a4309c9c595c18657893
6
+ metadata.gz: e14922a83ea7acc09c60b028b837df3eac6a65514f3b087086521261f844cbc54d89f90e5780df46a30c10b068bfcf88aa3e04ebea7f9bb749cd334f7481b87a
7
+ data.tar.gz: d6439354aa07699acc613520c7ee43e99e9ccd9cba113aff99fd6c81159964820afc47b1c2bb494be6b3517dc7c3100cbe4f2724be26cf720d4aade68a316e7e
data/README.md CHANGED
@@ -9,12 +9,16 @@ Full API description, including API parameters etc, is available from [Betfair's
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'betfair', github: 'mikecmpbll/betfair'
12
+ gem 'betfair-ng'
13
13
  ```
14
14
 
15
15
  And then execute:
16
16
 
17
17
  $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install betfair-ng
18
22
 
19
23
  ## Usage
20
24
 
@@ -87,6 +91,10 @@ client.place_orders({
87
91
  client.logout
88
92
  ```
89
93
 
94
+ ## Todo
95
+
96
+ 1. Error handling
97
+
90
98
  ## Contributing
91
99
 
92
100
  1. Fork it ( https://github.com/mikecmpbll/betfair/fork )
@@ -33,11 +33,24 @@ module Betfair
33
33
  headers: { "Content-Type" => "application/x-www-form-urlencoded" }
34
34
  })
35
35
 
36
- session_token = json["token"]
36
+ add_session_token_to_persistent_headers(json["token"])
37
+ end
37
38
 
38
- persistent_headers.merge!({
39
- "X-Authentication" => session_token
39
+ # Performs the login procedure recommended for applications which run autonomously
40
+ # username: Betfair account username string
41
+ # password: Betfair account password string
42
+ # cert_key_file_path: Path to Betfair client certificate private key file
43
+ # cert_key_path: Path to Betfair client certificate public key file associated with Betfair account
44
+ def non_interactive_login(username, password, cert_key_file_path, cert_file_path)
45
+ json = post({
46
+ url: "https://identitysso.betfair.com/api/certlogin",
47
+ body: { username: username, password: password },
48
+ headers: { "Content-Type" => "application/x-www-form-urlencoded" },
49
+ cert_key_file_path: cert_key_file_path,
50
+ cert_file_path: cert_file_path
40
51
  })
52
+
53
+ add_session_token_to_persistent_headers(json["sessionToken"])
41
54
  end
42
55
 
43
56
  def logout
@@ -52,6 +65,12 @@ module Betfair
52
65
  end
53
66
  end
54
67
 
68
+ def add_session_token_to_persistent_headers(session_token)
69
+ persistent_headers.merge!({
70
+ "X-Authentication" => session_token
71
+ })
72
+ end
73
+
55
74
  def parse_response(response)
56
75
  JSON.parse(response).tap { |r| handle_errors(r) }
57
76
  end
@@ -40,8 +40,14 @@ module Betfair
40
40
 
41
41
  def configure_request(opts = {})
42
42
  opts[:headers] = persistent_headers.merge(opts[:headers] || {})
43
+ request = HTTPI::Request.new(opts)
43
44
 
44
- HTTPI::Request.new(opts)
45
+ # It would be nice to have HTTPI do this itself but HTTPI::Request#mass_assign doesn't merge auth fields
46
+ unless opts[:cert_file_path].nil? or opts[:cert_key_file_path].nil?
47
+ request.auth.ssl.cert_key_file = opts[:cert_key_file_path]
48
+ request.auth.ssl.cert_file = opts[:cert_file_path]
49
+ end
50
+ request
45
51
  end
46
52
 
47
53
  def extend_api(type)
@@ -1,3 +1,3 @@
1
1
  module Betfair
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betfair-ng
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Campbell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-26 00:00:00.000000000 Z
11
+ date: 2015-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler