betfair_api_ng_rails 0.0.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -28
  3. data/Rakefile +10 -1
  4. data/betfair_api_ng_rails.gemspec +3 -0
  5. data/lib/betfair_api_ng_rails.rb +92 -73
  6. data/lib/betfair_api_ng_rails/api/concerns/errorable.rb +19 -0
  7. data/lib/betfair_api_ng_rails/api/config.rb +27 -0
  8. data/lib/betfair_api_ng_rails/api/connection.rb +34 -0
  9. data/lib/betfair_api_ng_rails/api/connection_ext/formatting.rb +34 -0
  10. data/lib/betfair_api_ng_rails/api/connection_ext/parsing.rb +29 -0
  11. data/lib/betfair_api_ng_rails/api/constants.rb +51 -0
  12. data/lib/betfair_api_ng_rails/api/data/attributes.rb +50 -0
  13. data/lib/betfair_api_ng_rails/api/data/base.rb +16 -0
  14. data/lib/betfair_api_ng_rails/api/data/competition.rb +20 -0
  15. data/lib/betfair_api_ng_rails/api/data/competition_result.rb +21 -0
  16. data/lib/betfair_api_ng_rails/api/data/concerns/hashable.rb +29 -0
  17. data/lib/betfair_api_ng_rails/api/data/constants.rb +11 -0
  18. data/lib/betfair_api_ng_rails/api/data/country_code_result.rb +19 -0
  19. data/lib/betfair_api_ng_rails/api/data/event.rb +20 -0
  20. data/lib/betfair_api_ng_rails/api/data/event_result.rb +19 -0
  21. data/lib/betfair_api_ng_rails/api/data/event_type.rb +20 -0
  22. data/lib/betfair_api_ng_rails/api/data/event_type_result.rb +19 -0
  23. data/lib/betfair_api_ng_rails/api/data/market_filter.rb +16 -0
  24. data/lib/betfair_api_ng_rails/api/data/market_type_result.rb +19 -0
  25. data/lib/betfair_api_ng_rails/api/data/time_range.rb +20 -0
  26. data/lib/betfair_api_ng_rails/api/data/time_range_result.rb +19 -0
  27. data/lib/betfair_api_ng_rails/api/data/venue_result.rb +19 -0
  28. data/lib/betfair_api_ng_rails/api/enums/bet_status.rb +15 -0
  29. data/lib/betfair_api_ng_rails/api/enums/concerns/enumable.rb +15 -0
  30. data/lib/betfair_api_ng_rails/api/enums/execution_report_error_code.rb +28 -0
  31. data/lib/betfair_api_ng_rails/api/enums/execution_report_status.rb +15 -0
  32. data/lib/betfair_api_ng_rails/api/enums/group_by.rb +17 -0
  33. data/lib/betfair_api_ng_rails/api/enums/instruction_report_error_code.rb +31 -0
  34. data/lib/betfair_api_ng_rails/api/enums/instruction_report_status.rb +14 -0
  35. data/lib/betfair_api_ng_rails/api/enums/market_betting_type.rb +17 -0
  36. data/lib/betfair_api_ng_rails/api/enums/market_projection.rb +18 -0
  37. data/lib/betfair_api_ng_rails/api/enums/market_sort.rb +17 -0
  38. data/lib/betfair_api_ng_rails/api/enums/market_status.rb +15 -0
  39. data/lib/betfair_api_ng_rails/api/enums/match_projection.rb +14 -0
  40. data/lib/betfair_api_ng_rails/api/enums/order_by.rb +14 -0
  41. data/lib/betfair_api_ng_rails/api/enums/order_projection.rb +14 -0
  42. data/lib/betfair_api_ng_rails/api/enums/order_status.rb +13 -0
  43. data/lib/betfair_api_ng_rails/api/enums/order_type.rb +14 -0
  44. data/lib/betfair_api_ng_rails/api/enums/persistence_type.rb +14 -0
  45. data/lib/betfair_api_ng_rails/api/enums/price_data.rb +16 -0
  46. data/lib/betfair_api_ng_rails/api/enums/rollup_model.rb +15 -0
  47. data/lib/betfair_api_ng_rails/api/enums/runner_status.rb +17 -0
  48. data/lib/betfair_api_ng_rails/api/enums/side.rb +13 -0
  49. data/lib/betfair_api_ng_rails/api/enums/sort_dir.rb +13 -0
  50. data/lib/betfair_api_ng_rails/api/enums/time_granularity.rb +14 -0
  51. data/lib/betfair_api_ng_rails/api/formatter_factory.rb +1 -1
  52. data/lib/betfair_api_ng_rails/api/formatters/js_tree_formatter.rb +38 -0
  53. data/lib/betfair_api_ng_rails/api/hashalator.rb +39 -0
  54. data/lib/betfair_api_ng_rails/api/helper.rb +29 -0
  55. data/lib/betfair_api_ng_rails/api/http/factory.rb +41 -0
  56. data/lib/betfair_api_ng_rails/api/http/helpers/information_response.rb +35 -0
  57. data/lib/betfair_api_ng_rails/api/http/helpers/keep_alive_response.rb +32 -0
  58. data/lib/betfair_api_ng_rails/api/http/helpers/session_response.rb +36 -0
  59. data/lib/betfair_api_ng_rails/api/http/requester.rb +75 -0
  60. data/lib/betfair_api_ng_rails/api/http/responser.rb +47 -0
  61. data/lib/betfair_api_ng_rails/api/parsers/base.rb +31 -0
  62. data/lib/betfair_api_ng_rails/api/parsers/list_competitions.rb +15 -0
  63. data/lib/betfair_api_ng_rails/api/parsers/list_countries.rb +15 -0
  64. data/lib/betfair_api_ng_rails/api/parsers/list_event_types.rb +15 -0
  65. data/lib/betfair_api_ng_rails/api/parsers/list_events.rb +15 -0
  66. data/lib/betfair_api_ng_rails/api/parsers/list_market_types.rb +15 -0
  67. data/lib/betfair_api_ng_rails/api/parsers/list_time_ranges.rb +15 -0
  68. data/lib/betfair_api_ng_rails/api/parsers/list_venues.rb +15 -0
  69. data/lib/betfair_api_ng_rails/api/provider.rb +38 -0
  70. data/lib/betfair_api_ng_rails/api/request_methods.rb +33 -0
  71. data/lib/betfair_api_ng_rails/api/session_manager.rb +54 -0
  72. data/lib/betfair_api_ng_rails/errors.rb +6 -0
  73. data/lib/betfair_api_ng_rails/railtie.rb +7 -0
  74. data/lib/betfair_api_ng_rails/version.rb +1 -1
  75. data/lib/generators/betfair_api_ng_rails/install/templates/betfair_api_ng_rails.rb +11 -9
  76. data/lib/generators/betfair_api_ng_rails/install/templates/betfair_api_ng_rails.yml +2 -0
  77. data/spec/betfair_api_ng_rails/api/connection_spec.rb +74 -0
  78. data/spec/betfair_api_ng_rails/api/data/concerns/hashable_spec.rb +81 -0
  79. data/spec/betfair_api_ng_rails/api/formatters/js_tree_formatter_spec.rb +70 -0
  80. data/spec/betfair_api_ng_rails/api/hashalator_spec.rb +146 -0
  81. data/spec/betfair_api_ng_rails/api/provider_spec.rb +91 -0
  82. data/spec/betfair_api_ng_rails/api/request_methods_spec.rb +60 -0
  83. data/spec/betfair_api_ng_rails/api/session_manager_spec.rb +59 -0
  84. data/spec/betfair_api_ng_rails/integration/list_competitions_spec.rb +18 -0
  85. data/spec/betfair_api_ng_rails/integration/list_countries_spec.rb +18 -0
  86. data/spec/betfair_api_ng_rails/integration/list_event_types_spec.rb +18 -0
  87. data/spec/betfair_api_ng_rails/integration/list_events_spec.rb +18 -0
  88. data/spec/betfair_api_ng_rails/integration/list_market_types_spec.rb +18 -0
  89. data/spec/betfair_api_ng_rails/integration/list_time_ranges_spec.rb +18 -0
  90. data/spec/betfair_api_ng_rails/integration/list_venues_spec.rb +18 -0
  91. data/spec/spec_helper.rb +16 -0
  92. data/spec/support/shared_examples/request_method.rb +18 -0
  93. data/spec/support/shared_examples/simple_list_filtering_request.rb +51 -0
  94. metadata +156 -66
  95. data/lib/betfair_api_ng_rails/api/base_provider.rb +0 -15
  96. data/lib/betfair_api_ng_rails/api/bf/concerns/errorable.rb +0 -21
  97. data/lib/betfair_api_ng_rails/api/bf/config.rb +0 -27
  98. data/lib/betfair_api_ng_rails/api/bf/constants.rb +0 -37
  99. data/lib/betfair_api_ng_rails/api/bf/data/attributes.rb +0 -52
  100. data/lib/betfair_api_ng_rails/api/bf/data/base.rb +0 -17
  101. data/lib/betfair_api_ng_rails/api/bf/data/competition.rb +0 -26
  102. data/lib/betfair_api_ng_rails/api/bf/data/competition_result.rb +0 -23
  103. data/lib/betfair_api_ng_rails/api/bf/data/concerns/hashable.rb +0 -40
  104. data/lib/betfair_api_ng_rails/api/bf/data/concerns/querable.rb +0 -46
  105. data/lib/betfair_api_ng_rails/api/bf/data/constants.rb +0 -13
  106. data/lib/betfair_api_ng_rails/api/bf/data/event.rb +0 -26
  107. data/lib/betfair_api_ng_rails/api/bf/data/event_result.rb +0 -21
  108. data/lib/betfair_api_ng_rails/api/bf/data/event_type.rb +0 -26
  109. data/lib/betfair_api_ng_rails/api/bf/data/event_type_result.rb +0 -21
  110. data/lib/betfair_api_ng_rails/api/bf/data/market_filter.rb +0 -19
  111. data/lib/betfair_api_ng_rails/api/bf/data/time_range.rb +0 -18
  112. data/lib/betfair_api_ng_rails/api/bf/data/time_range_result.rb +0 -21
  113. data/lib/betfair_api_ng_rails/api/bf/enums/bet_status.rb +0 -17
  114. data/lib/betfair_api_ng_rails/api/bf/enums/concerns/enumable.rb +0 -17
  115. data/lib/betfair_api_ng_rails/api/bf/enums/execution_report_error_code.rb +0 -30
  116. data/lib/betfair_api_ng_rails/api/bf/enums/execution_report_status.rb +0 -17
  117. data/lib/betfair_api_ng_rails/api/bf/enums/group_by.rb +0 -19
  118. data/lib/betfair_api_ng_rails/api/bf/enums/instruction_report_error_code.rb +0 -33
  119. data/lib/betfair_api_ng_rails/api/bf/enums/instruction_report_status.rb +0 -16
  120. data/lib/betfair_api_ng_rails/api/bf/enums/market_betting_type.rb +0 -19
  121. data/lib/betfair_api_ng_rails/api/bf/enums/market_projection.rb +0 -20
  122. data/lib/betfair_api_ng_rails/api/bf/enums/market_sort.rb +0 -19
  123. data/lib/betfair_api_ng_rails/api/bf/enums/market_status.rb +0 -17
  124. data/lib/betfair_api_ng_rails/api/bf/enums/match_projection.rb +0 -16
  125. data/lib/betfair_api_ng_rails/api/bf/enums/order_by.rb +0 -16
  126. data/lib/betfair_api_ng_rails/api/bf/enums/order_projection.rb +0 -16
  127. data/lib/betfair_api_ng_rails/api/bf/enums/order_status.rb +0 -15
  128. data/lib/betfair_api_ng_rails/api/bf/enums/order_type.rb +0 -16
  129. data/lib/betfair_api_ng_rails/api/bf/enums/persistence_type.rb +0 -16
  130. data/lib/betfair_api_ng_rails/api/bf/enums/price_data.rb +0 -18
  131. data/lib/betfair_api_ng_rails/api/bf/enums/rollup_model.rb +0 -17
  132. data/lib/betfair_api_ng_rails/api/bf/enums/runner_status.rb +0 -19
  133. data/lib/betfair_api_ng_rails/api/bf/enums/side.rb +0 -15
  134. data/lib/betfair_api_ng_rails/api/bf/enums/sort_dir.rb +0 -15
  135. data/lib/betfair_api_ng_rails/api/bf/enums/time_granularity.rb +0 -16
  136. data/lib/betfair_api_ng_rails/api/bf/formatters/js_tree_formatter.rb +0 -30
  137. data/lib/betfair_api_ng_rails/api/bf/helper.rb +0 -33
  138. data/lib/betfair_api_ng_rails/api/bf/http/factory.rb +0 -37
  139. data/lib/betfair_api_ng_rails/api/bf/http/requester.rb +0 -69
  140. data/lib/betfair_api_ng_rails/api/bf/http/responser.rb +0 -58
  141. data/lib/betfair_api_ng_rails/api/bf/orm/parsers/base.rb +0 -33
  142. data/lib/betfair_api_ng_rails/api/bf/orm/parsers/list_competitions.rb +0 -19
  143. data/lib/betfair_api_ng_rails/api/bf/orm/parsers/list_event_types.rb +0 -19
  144. data/lib/betfair_api_ng_rails/api/bf/orm/parsers/list_events.rb +0 -19
  145. data/lib/betfair_api_ng_rails/api/bf/orm/requester.rb +0 -52
  146. data/lib/betfair_api_ng_rails/api/bf/provider.rb +0 -38
  147. data/lib/betfair_api_ng_rails/api/bf/session_manager.rb +0 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf7f63ee0737110869e21a922b12a4aa99850019
4
- data.tar.gz: bed144ea5a16997275538b8fd88b1566413e6b64
3
+ metadata.gz: c20bda2211a6be34fbfffba46eb548faf580d3a3
4
+ data.tar.gz: 81c228df7a738da9bc5156485567ea34ab566820
5
5
  SHA512:
6
- metadata.gz: 86b7d9ab358b32912b1fe5e4a1bf2b56a8cd731f976a1e82268c0ca843dc03bda4aa94ec2da6e65edd34382b39c62ac60c8bb073bfd0b96ebde826f63c0a64d4
7
- data.tar.gz: b437d15bea1d28fc5cbce55c6ad5bb8b1274249382d4f3b8a0ab38e0db0140534c14c2bae652497c98ec40c0f17deb163891736c7e2843382a0b5209bb373d9f
6
+ metadata.gz: a08183228cab41b7d28a52cc86328cdba3fcedc80a5aec045cf752810aa825ea8b1fc66c35a92dd71f2f008169592596e53bb295d8342232aa53ab74fdd451d4
7
+ data.tar.gz: 20693a5383bb7bcceb79d35977090acda984cd3327498c47160528dcadc2a98c438ba91fe8645bebc795f7b9a16fd143b8de5afe658e3df6eb855902ef9db9a3
data/README.md CHANGED
@@ -6,7 +6,7 @@ API-NG is Betfair's next generation API for developers looking to create automat
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'betfair_api_ng_rails'
9
+ gem 'betfair_api_ng_rails', '1.0.0'
10
10
 
11
11
  And then execute:
12
12
 
@@ -35,26 +35,13 @@ In this files you must specify credentials to API-NG. Also you should notice tha
35
35
 
36
36
  ## Usage
37
37
 
38
- Sample code for fetching all competitions:
38
+ Please check [wiki pages](https://github.com/alterego-labs/betfair_api_ng_rails/wiki). It will be available soon...
39
39
 
40
- ```ruby
41
- result = BetfairApiNgRails::Competition.all
42
- ```
43
-
44
- For all available methods see [there](https://api.developer.betfair.com/services/webapps/docs/display/1smk3cen4v3lu3yomq5qye0ni/Betting+Operations).
45
-
46
- Also you may passing filtering params:
47
-
48
- ```ruby
49
- filter = BetfairApiNgRails::MarketFilter.new text_query: 'World*'
50
- result = BetfairApiNgRails::Competition.where filter: filter
51
- ```
52
-
53
- Or fetching competition by identifier:
40
+ ## CHANGES IN 1.0.0
54
41
 
55
- ```ruby
56
- result = BetfairApiNgRails::Competition.find 1
57
- ```
42
+ 1. Replaced ActiveRecord style querying by more similar structure to API-NG
43
+ 2. Starting to testing
44
+ 3. Refactoring
58
45
 
59
46
  ## CHANGES IN 0.0.8
60
47
 
@@ -64,15 +51,6 @@ result = BetfairApiNgRails::Competition.find 1
64
51
  4. Added shortcuts for models
65
52
  5. Refactoring
66
53
 
67
- ## CHANGES IN 0.0.7!!!
68
-
69
- Now gem used Object model for doing requests and it's results that is based on [betfair's type definitions](https://api.developer.betfair.com/services/webapps/docs/display/1smk3cen4v3lu3yomq5qye0ni/Betting+Type+Definitions#BettingTypeDefinitions-UpdateInstruction).
70
-
71
- ## WARNING!!!
72
-
73
- __Last version of gem supports only listCompetitions, listEventTypes and listEvents requests.__ I will provide more powerful functional soon.
74
-
75
-
76
54
  ## Contributing
77
55
 
78
56
  1. Fork it
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
- require "bundler/gem_tasks"
1
+ require "rubygems"
2
+ require 'rspec/core/rake_task'
3
+ require 'rubygems/specification'
4
+
5
+ task default: :spec
6
+ desc "Run specs"
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.pattern = FileList['spec/**/*_spec.rb']
9
+ t.rspec_opts = %w(--color)
10
+ end
@@ -21,4 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "activesupport", ">= 3.1.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0.0.beta"
25
+ spec.add_development_dependency "rspec-its"
26
+ spec.add_development_dependency "pry-nav"
24
27
  end
@@ -1,4 +1,7 @@
1
1
  require "betfair_api_ng_rails/version"
2
+ require "betfair_api_ng_rails/errors"
3
+ require "betfair_api_ng_rails/api/request_methods"
4
+ require "betfair_api_ng_rails/railtie" if defined?(Rails)
2
5
 
3
6
  module BetfairApiNgRails
4
7
 
@@ -8,108 +11,124 @@ module BetfairApiNgRails
8
11
  autoload :BaseRequester, 'betfair_api_ng_rails/api/base_requester'
9
12
  autoload :FormatterFactory, 'betfair_api_ng_rails/api/formatter_factory'
10
13
 
11
- module BF
14
+ autoload :Config, 'betfair_api_ng_rails/api/config'
15
+ autoload :Constants, 'betfair_api_ng_rails/api/constants'
16
+ autoload :Provider, 'betfair_api_ng_rails/api/provider'
17
+ autoload :SessionManager, 'betfair_api_ng_rails/api/session_manager'
12
18
 
13
- autoload :Config, 'betfair_api_ng_rails/api/bf/config'
14
- autoload :Constants, 'betfair_api_ng_rails/api/bf/constants'
15
- autoload :Provider, 'betfair_api_ng_rails/api/bf/provider'
16
- autoload :SessionManager, 'betfair_api_ng_rails/api/bf/session_manager'
19
+ autoload :Connection, 'betfair_api_ng_rails/api/connection'
20
+ autoload :Hashalator, 'betfair_api_ng_rails/api/hashalator'
17
21
 
18
- module Formatters
22
+ module Formatters
19
23
 
20
- autoload :JsTreeFormatter, 'betfair_api_ng_rails/api/bf/formatters/js_tree_formatter'
24
+ autoload :JsTreeFormatter, 'betfair_api_ng_rails/api/formatters/js_tree_formatter'
21
25
 
22
- end
23
-
24
- module Data
26
+ end
25
27
 
26
- autoload :Base, 'betfair_api_ng_rails/api/bf/data/base'
27
- autoload :Attributes, 'betfair_api_ng_rails/api/bf/data/attributes'
28
- autoload :Constants, 'betfair_api_ng_rails/api/bf/data/constants'
29
- autoload :Competition, 'betfair_api_ng_rails/api/bf/data/competition'
30
- autoload :CompetitionResult, 'betfair_api_ng_rails/api/bf/data/competition_result'
31
- autoload :MarketFilter, 'betfair_api_ng_rails/api/bf/data/market_filter'
32
- autoload :TimeRange, 'betfair_api_ng_rails/api/bf/data/time_range'
33
- autoload :TimeRangeResult, 'betfair_api_ng_rails/api/bf/data/time_range_result'
34
- autoload :EventType, 'betfair_api_ng_rails/api/bf/data/event_type'
35
- autoload :EventTypeResult, 'betfair_api_ng_rails/api/bf/data/event_type_result'
36
- autoload :Event, 'betfair_api_ng_rails/api/bf/data/event'
37
- autoload :EventResult, 'betfair_api_ng_rails/api/bf/data/event_result'
28
+ module Data
38
29
 
39
- module Concerns
30
+ autoload :Base, 'betfair_api_ng_rails/api/data/base'
31
+ autoload :Attributes, 'betfair_api_ng_rails/api/data/attributes'
32
+ autoload :Constants, 'betfair_api_ng_rails/api/data/constants'
33
+ autoload :Competition, 'betfair_api_ng_rails/api/data/competition'
34
+ autoload :CompetitionResult, 'betfair_api_ng_rails/api/data/competition_result'
35
+ autoload :MarketFilter, 'betfair_api_ng_rails/api/data/market_filter'
36
+ autoload :TimeRange, 'betfair_api_ng_rails/api/data/time_range'
37
+ autoload :TimeRangeResult, 'betfair_api_ng_rails/api/data/time_range_result'
38
+ autoload :EventType, 'betfair_api_ng_rails/api/data/event_type'
39
+ autoload :EventTypeResult, 'betfair_api_ng_rails/api/data/event_type_result'
40
+ autoload :Event, 'betfair_api_ng_rails/api/data/event'
41
+ autoload :EventResult, 'betfair_api_ng_rails/api/data/event_result'
42
+ autoload :CountryCodeResult, 'betfair_api_ng_rails/api/data/country_code_result'
43
+ autoload :VenueResult, 'betfair_api_ng_rails/api/data/venue_result'
44
+ autoload :MarketTypeResult, 'betfair_api_ng_rails/api/data/market_type_result'
40
45
 
41
- autoload :Hashable, 'betfair_api_ng_rails/api/bf/data/concerns/hashable'
42
- autoload :Querable, 'betfair_api_ng_rails/api/bf/data/concerns/querable'
46
+ module Concerns
43
47
 
44
- end
48
+ autoload :Hashable, 'betfair_api_ng_rails/api/data/concerns/hashable'
45
49
 
46
50
  end
47
51
 
48
- module Enums
49
-
50
- autoload :MarketProjection, 'betfair_api_ng_rails/api/bf/enums/market_projection'
51
- autoload :PriceData, 'betfair_api_ng_rails/api/bf/enums/price_data'
52
- autoload :MatchProjection, 'betfair_api_ng_rails/api/bf/enums/match_projection'
53
- autoload :OrderProjection, 'betfair_api_ng_rails/api/bf/enums/order_projection'
54
- autoload :MarketStatus, 'betfair_api_ng_rails/api/bf/enums/market_status'
55
- autoload :RunnerStatus, 'betfair_api_ng_rails/api/bf/enums/runner_status'
56
- autoload :TimeGranularity, 'betfair_api_ng_rails/api/bf/enums/time_granularity'
57
- autoload :Side, 'betfair_api_ng_rails/api/bf/enums/side'
58
- autoload :OrderStatus, 'betfair_api_ng_rails/api/bf/enums/order_status'
59
- autoload :OrderBy, 'betfair_api_ng_rails/api/bf/enums/order_by'
60
- autoload :SortDir, 'betfair_api_ng_rails/api/bf/enums/sort_dir'
61
- autoload :OrderType, 'betfair_api_ng_rails/api/bf/enums/order_type'
62
- autoload :MarketSort, 'betfair_api_ng_rails/api/bf/enums/market_sort'
63
- autoload :MarketBettingType, 'betfair_api_ng_rails/api/bf/enums/market_betting_type'
64
- autoload :ExecutionReportStatus, 'betfair_api_ng_rails/api/bf/enums/execution_report_status'
65
- autoload :ExecutionReportErrorCode, 'betfair_api_ng_rails/api/bf/enums/execution_report_error_code'
66
- autoload :PersistenceType, 'betfair_api_ng_rails/api/bf/enums/perisstence_type'
67
- autoload :InstrictionReportStatus, 'betfair_api_ng_rails/api/bf/enums/instruction_report_status'
68
- autoload :InstructionReportErrorCode, 'betfair_api_ng_rails/api/bf/enums/instruction_report_error_code'
69
- autoload :RollupModel, 'betfair_api_ng_rails/api/bf/enums/rollup_model'
70
- autoload :GroupBy, 'betfair_api_ng_rails/api/bf/enums/group_by'
71
- autoload :BetStatus, 'betfair_api_ng_rails/api/bf/enums/bet_status'
72
-
73
- module Concerns
74
-
75
- autoload :Enumable, 'betfair_api_ng_rails/api/bf/enums/concerns/enumable'
76
-
77
- end
52
+ end
53
+
54
+ module Enums
55
+
56
+ autoload :MarketProjection, 'betfair_api_ng_rails/api/enums/market_projection'
57
+ autoload :PriceData, 'betfair_api_ng_rails/api/enums/price_data'
58
+ autoload :MatchProjection, 'betfair_api_ng_rails/api/enums/match_projection'
59
+ autoload :OrderProjection, 'betfair_api_ng_rails/api/enums/order_projection'
60
+ autoload :MarketStatus, 'betfair_api_ng_rails/api/enums/market_status'
61
+ autoload :RunnerStatus, 'betfair_api_ng_rails/api/enums/runner_status'
62
+ autoload :TimeGranularity, 'betfair_api_ng_rails/api/enums/time_granularity'
63
+ autoload :Side, 'betfair_api_ng_rails/api/enums/side'
64
+ autoload :OrderStatus, 'betfair_api_ng_rails/api/enums/order_status'
65
+ autoload :OrderBy, 'betfair_api_ng_rails/api/enums/order_by'
66
+ autoload :SortDir, 'betfair_api_ng_rails/api/enums/sort_dir'
67
+ autoload :OrderType, 'betfair_api_ng_rails/api/enums/order_type'
68
+ autoload :MarketSort, 'betfair_api_ng_rails/api/enums/market_sort'
69
+ autoload :MarketBettingType, 'betfair_api_ng_rails/api/enums/market_betting_type'
70
+ autoload :ExecutionReportStatus, 'betfair_api_ng_rails/api/enums/execution_report_status'
71
+ autoload :ExecutionReportErrorCode, 'betfair_api_ng_rails/api/enums/execution_report_error_code'
72
+ autoload :PersistenceType, 'betfair_api_ng_rails/api/enums/perisstence_type'
73
+ autoload :InstrictionReportStatus, 'betfair_api_ng_rails/api/enums/instruction_report_status'
74
+ autoload :InstructionReportErrorCode, 'betfair_api_ng_rails/api/enums/instruction_report_error_code'
75
+ autoload :RollupModel, 'betfair_api_ng_rails/api/enums/rollup_model'
76
+ autoload :GroupBy, 'betfair_api_ng_rails/api/enums/group_by'
77
+ autoload :BetStatus, 'betfair_api_ng_rails/api/enums/bet_status'
78
+
79
+ module Concerns
80
+
81
+ autoload :Enumable, 'betfair_api_ng_rails/api/enums/concerns/enumable'
78
82
 
79
83
  end
80
84
 
81
- module Http
82
-
83
- autoload :Requester, 'betfair_api_ng_rails/api/bf/http/requester'
84
- autoload :Responser, 'betfair_api_ng_rails/api/bf/http/responser'
85
- autoload :Factory, 'betfair_api_ng_rails/api/bf/http/factory'
85
+ end
86
86
 
87
- end
87
+ module Http
88
88
 
89
- module ORM
89
+ autoload :Requester, 'betfair_api_ng_rails/api/http/requester'
90
+ autoload :Responser, 'betfair_api_ng_rails/api/http/responser'
91
+ autoload :Factory, 'betfair_api_ng_rails/api/http/factory'
90
92
 
91
- autoload :Requester, 'betfair_api_ng_rails/api/bf/orm/requester'
93
+ end
92
94
 
93
- module Parsers
95
+ module Parsers
94
96
 
95
- autoload :Base, 'betfair_api_ng_rails/api/bf/orm/parsers/base'
96
- autoload :ListCompetitions, 'betfair_api_ng_rails/api/bf/orm/parsers/list_competitions'
97
- autoload :ListEventTypes, 'betfair_api_ng_rails/api/bf/orm/parsers/list_event_types'
98
- autoload :ListEvents, 'betfair_api_ng_rails/api/bf/orm/parsers/list_events'
97
+ autoload :Base, 'betfair_api_ng_rails/api/parsers/base'
98
+ autoload :ListCompetitions, 'betfair_api_ng_rails/api/parsers/list_competitions'
99
+ autoload :ListEventTypes, 'betfair_api_ng_rails/api/parsers/list_event_types'
100
+ autoload :ListEvents, 'betfair_api_ng_rails/api/parsers/list_events'
101
+ autoload :ListTimeRanges, 'betfair_api_ng_rails/api/parsers/list_time_ranges'
102
+ autoload :ListCountries, 'betfair_api_ng_rails/api/parsers/list_countries'
103
+ autoload :ListVenues, 'betfair_api_ng_rails/api/parsers/list_venues'
104
+ autoload :ListMarketTypes, 'betfair_api_ng_rails/api/parsers/list_market_types'
99
105
 
100
- end
106
+ end
101
107
 
102
- end
108
+ module ConnectionExt
109
+
110
+ autoload :Parsing, 'betfair_api_ng_rails/api/connection_ext/parsing'
111
+ autoload :Formatting, 'betfair_api_ng_rails/api/connection_ext/formatting'
103
112
 
104
113
  end
105
114
 
106
115
  end
107
116
 
108
- include Api::BF::Data
117
+ include Api::Data
118
+ extend Api::RequestMethods
109
119
 
110
120
  def self.config(&block)
111
- @_config ||= BetfairApiNgRails::Api::BF::Config
121
+ @_config ||= BetfairApiNgRails::Api::Config
112
122
  block_given? ? yield(@_config) : @_config
113
123
  end
114
124
 
125
+ def self.connection
126
+ raise BetfairApiNgRails::NoConnectionError unless @connection
127
+ @connection
128
+ end
129
+
130
+ def self.connection=(value)
131
+ @connection = value
132
+ end
133
+
115
134
  end
@@ -0,0 +1,19 @@
1
+ require 'active_support/core_ext/object'
2
+
3
+ module BetfairApiNgRails
4
+ module Api
5
+ module Concerns
6
+ module Errorable
7
+
8
+ def has_errors?
9
+ !error_info.nil?
10
+ end
11
+
12
+ def error_info
13
+ @http_responser.try(:error_info?)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ class Config
4
+
5
+ class << self
6
+
7
+ attr_accessor :application_key,
8
+ :ssl_key_filepath,
9
+ :ssl_crt_filepath,
10
+ :login_url,
11
+ :api_url,
12
+ :username,
13
+ :password,
14
+ :locale,
15
+ :formatter,
16
+ :keep_alive_session,
17
+ :keep_alive_url
18
+
19
+ def formatter=(value)
20
+ @formatter = BetfairApiNgRails::Api::FormatterFactory.initialize_formatter value
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ class Connection
4
+
5
+ attr_reader :ssoid
6
+
7
+ def initialize
8
+ request_ssoid
9
+ end
10
+
11
+ def request(method, params = {})
12
+ provider.fetch method: method, params: hashing(params)
13
+ end
14
+
15
+ include Api::ConnectionExt::Parsing
16
+ include Api::ConnectionExt::Formatting
17
+
18
+ protected
19
+
20
+ def provider
21
+ @_provider ||= BetfairApiNgRails::Api::Provider.new ssoid
22
+ end
23
+
24
+ def request_ssoid
25
+ @ssoid = BetfairApiNgRails::Api::SessionManager.new_ssoid
26
+ end
27
+
28
+ def hashing(params)
29
+ BetfairApiNgRails::Api::Hashalator.new(params).to_hash
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ require 'active_support/inflector'
2
+ require 'pry-nav'
3
+
4
+ module BetfairApiNgRails
5
+ module Api
6
+ module ConnectionExt
7
+ module Formatting
8
+ include BetfairApiNgRails::Api::Constants
9
+
10
+ def self.included(base)
11
+ base.send :class_eval, <<-CODE
12
+ def request_with_formatting(method, params = {})
13
+ res = request_without_formatting(method, params)
14
+ need_formatting_for?(method) ? formatting(method, res) : res
15
+ end
16
+ alias_method :request_without_formatting, :request
17
+ alias_method :request, :request_with_formatting
18
+ CODE
19
+ end
20
+
21
+ private
22
+
23
+ def formatting(method, result)
24
+ BetfairApiNgRails.config.formatter.process result, as: method
25
+ end
26
+
27
+ def need_formatting_for?(method)
28
+ ALLOWED_FORMATTING.include?(method) && BetfairApiNgRails.config.formatter
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,29 @@
1
+ require 'active_support/inflector'
2
+ require 'pry-nav'
3
+
4
+ module BetfairApiNgRails
5
+ module Api
6
+ module ConnectionExt
7
+ module Parsing
8
+
9
+ def self.included(base)
10
+ base.send :class_eval, <<-CODE
11
+ def request_with_parsing(method, params = {})
12
+ res = request_without_parsing(method, params)
13
+ init_parser(method, res).process
14
+ end
15
+ alias_method :request_without_parsing, :request
16
+ alias_method :request, :request_with_parsing
17
+ CODE
18
+ end
19
+
20
+ private
21
+
22
+ def init_parser(method, responser)
23
+ "BetfairApiNgRails::Api::Parsers::#{method.camelize}".constantize.new responser
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,51 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Constants
4
+
5
+ SUCCESS_LOGIN = "SUCCESS"
6
+
7
+ PROVIDER_NAME = "BF"
8
+
9
+ SESSION_REQUEST_HEADERS = {
10
+ "Content-Type" => "application/x-www-form-urlencoded"
11
+ }
12
+
13
+ API_REQUEST_HEADERS = {
14
+ "Content-Type" => "application/json",
15
+ "Accept" => "application/json"
16
+ }
17
+
18
+ ALLOWED_RESOURCES = [
19
+ "listEventTypes",
20
+ "listCompetitions",
21
+ "listTimeRanges",
22
+ "listEvents",
23
+ "listMarketTypes",
24
+ "listCountries",
25
+ "listVenues",
26
+ "listMarketCatalogue",
27
+ "listMarketBook",
28
+ "listCurrentOrders",
29
+ "listClearedOrders",
30
+ "listMarketProfitAndLoss"
31
+ ]
32
+
33
+ ALLOWED_FORMATTING = [
34
+ "listEventTypes",
35
+ "listCompetitions",
36
+ "listEvents"
37
+ ]
38
+
39
+ SIMPLE_LISTING_FILTERED = [
40
+ "listEventTypes",
41
+ "listCompetitions",
42
+ "listTimeRanges",
43
+ "listEvents",
44
+ "listMarketTypes",
45
+ "listCountries",
46
+ "listVenues"
47
+ ]
48
+
49
+ end
50
+ end
51
+ end