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
@@ -1,15 +0,0 @@
1
- require 'active_support/inflector'
2
-
3
- module BetfairApiNgRails
4
- module Api
5
- class BaseProvider
6
-
7
- attr_reader :provider_name
8
-
9
- def fetch(method: "", filter: {}, params: {})
10
- raise "Must be reimplemented!"
11
- end
12
-
13
- end
14
- end
15
- end
@@ -1,21 +0,0 @@
1
- require 'active_support/core_ext/object'
2
-
3
- module BetfairApiNgRails
4
- module Api
5
- module BF
6
- module Concerns
7
- module Errorable
8
-
9
- def has_errors?
10
- !error_info.nil?
11
- end
12
-
13
- def error_info
14
- @http_responser.try(:error_info?)
15
- end
16
-
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,27 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- class Config
5
-
6
- class << self
7
-
8
- attr_accessor :application_key,
9
- :ssl_key_filepath,
10
- :ssl_crt_filepath,
11
- :login_url,
12
- :api_url,
13
- :username,
14
- :password,
15
- :locale,
16
- :formatter
17
-
18
- def formatter=(value)
19
- @formatter = BetfairApiNgRails::Api::FormatterFactory.initialize_formatter value
20
- end
21
-
22
- end
23
-
24
- end
25
- end
26
- end
27
- end
@@ -1,37 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Constants
5
-
6
- SUCCESS_LOGIN = "SUCCESS"
7
-
8
- PROVIDER_NAME = "BF"
9
-
10
- SESSION_REQUEST_HEADERS = {
11
- "Content-Type" => "application/x-www-form-urlencoded"
12
- }
13
-
14
- API_REQUEST_HEADERS = {
15
- "Content-Type" => "application/json",
16
- "Accept" => "application/json"
17
- }
18
-
19
- ALLOWED_RESOURCES = [
20
- "listEventTypes",
21
- "listCompetitions",
22
- "listTimeRanges",
23
- "listEvents",
24
- "listMarketTypes",
25
- "listCountries",
26
- "listVenues",
27
- "listMarketCatalogue",
28
- "listMarketBook",
29
- "listCurrentOrders",
30
- "listClearedOrders",
31
- "listMarketProfitAndLoss"
32
- ]
33
-
34
- end
35
- end
36
- end
37
- end
@@ -1,52 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- module Attributes
6
-
7
- MARKET_FILTER_ATTRS = [
8
- :text_query,
9
- :exchange_ids,
10
- :event_type_ids,
11
- :event_ids,
12
- :competition_ids,
13
- :venues,
14
- :bsp_only,
15
- :turn_in_play_enabled,
16
- :in_play_only,
17
- :market_betting_types,
18
- :market_countries,
19
- :market_type_codes,
20
- :market_start_time,
21
- :with_orders
22
- ]
23
-
24
- COMPETITION_ATTRS = [
25
- :id,
26
- :name
27
- ]
28
-
29
- EVENT_TYPE_ATTRS = [
30
- :id,
31
- :name
32
- ]
33
-
34
- EVENT_ATTRS = [
35
- :id,
36
- :name,
37
- :timezone,
38
- :country_code,
39
- :venue,
40
- :open_date
41
- ]
42
-
43
- TIME_RANGE_ATTRS = [
44
- :from,
45
- :to
46
- ]
47
-
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,17 +0,0 @@
1
- require 'active_support/inflector'
2
-
3
- module BetfairApiNgRails
4
- module Api
5
- module BF
6
- module Data
7
- class Base
8
-
9
- def initialize(args = {})
10
- args.each { |attribute, value| self.send("#{attribute}=", value) }
11
- end
12
-
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,26 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- class Competition < Api::BF::Data::Base
6
- include Api::BF::Data::Attributes
7
- extend Api::BF::Data::Concerns::Querable
8
- include Api::BF::Data::Concerns::Hashable
9
-
10
- attr_accessor *COMPETITION_ATTRS
11
-
12
- querable :competitions, :competition_ids
13
-
14
- def self.from_json(json_row)
15
- new COMPETITION_ATTRS.inject({}) { |h, a| h[a] = json_row[a.to_s.camelize(:lower)]; h }
16
- end
17
-
18
- def self.to_hash_attrs
19
- COMPETITION_ATTRS
20
- end
21
-
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,23 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- class CompetitionResult < Api::BF::Data::Base
6
-
7
- attr_accessor :market_count,
8
- :competition_region,
9
- :competition
10
-
11
- def self.from_json(json_row)
12
- new(
13
- competition: Api::BF::Data::Competition.from_json(json_row['competition']),
14
- market_count: json_row['marketCount'],
15
- competition_region: json_row['competitionRegion']
16
- )
17
- end
18
-
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,40 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- module Concerns
6
- module Hashable
7
- include BetfairApiNgRails::Api::BF::Data::Constants
8
-
9
- def to_hash
10
- self.class.to_hash_attrs.inject({}) do |h, attrib|
11
- val = get_attr_value(attrib)
12
- h[hash_key(attrib)] = hash_value(val) unless val.nil?
13
- h
14
- end
15
- end
16
-
17
- private
18
-
19
- def hash_value(val)
20
- need_to_hash?(val) ? val.to_hash : val
21
- end
22
-
23
- def need_to_hash?(val)
24
- !ATTRS_AS_IS.include?(val.class)
25
- end
26
-
27
- def get_attr_value(attrib)
28
- self.send attrib
29
- end
30
-
31
- def hash_key(attrib)
32
- attrib.to_s.camelize(:lower)
33
- end
34
-
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,46 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- module Concerns
6
- module Querable
7
-
8
- def querable(resource, find_attr = false)
9
- methods = <<-CODE
10
- #{where_query_method(resource)}
11
- #{all_query_method}
12
- #{find_query_method(find_attr) if find_attr}
13
- CODE
14
- instance_eval(methods)
15
- end
16
-
17
- private
18
-
19
- def where_query_method(resource)
20
- <<-STR
21
- def where(filter: Api::BF::Data::MarketFilter.new, params: {})
22
- Api::BF::ORM::Requester.load resource: :#{resource}, filter: filter, params: params
23
- end
24
- STR
25
- end
26
-
27
- def all_query_method
28
- <<-STR
29
- def all; where; end;
30
- STR
31
- end
32
-
33
- def find_query_method(find_attr)
34
- <<-STR
35
- def find(id)
36
- where filter: Api::BF::Data::MarketFilter.new(#{find_attr}: [id])
37
- end
38
- STR
39
- end
40
-
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,13 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- module Constants
6
-
7
- ATTRS_AS_IS = [Array, Hash, String, Symbol, Fixnum]
8
-
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,26 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- class Event < Api::BF::Data::Base
6
- include Api::BF::Data::Attributes
7
- extend Api::BF::Data::Concerns::Querable
8
- include Api::BF::Data::Concerns::Hashable
9
-
10
- attr_accessor *EVENT_ATTRS
11
-
12
- querable :events, :event_ids
13
-
14
- def self.from_json(json_row)
15
- new EVENT_ATTRS.inject({}) { |h, a| h[a] = json_row[a.to_s.camelize(:lower)]; h }
16
- end
17
-
18
- def self.to_hash_attrs
19
- EVENT_ATTRS
20
- end
21
-
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,21 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- class EventResult < Api::BF::Data::Base
6
-
7
- attr_accessor :market_count,
8
- :event
9
-
10
- def self.from_json(json_row)
11
- new(
12
- event: Api::BF::Data::Event.from_json(json_row['event']),
13
- market_count: json_row['marketCount']
14
- )
15
- end
16
-
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,26 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- class EventType < Api::BF::Data::Base
6
- include Api::BF::Data::Attributes
7
- extend Api::BF::Data::Concerns::Querable
8
- include Api::BF::Data::Concerns::Hashable
9
-
10
- attr_accessor *EVENT_TYPE_ATTRS
11
-
12
- querable :event_types, :event_type_ids
13
-
14
- def self.from_json(json_row)
15
- new EVENT_TYPE_ATTRS.inject({}) { |h, a| h[a] = json_row[a.to_s.camelize(:lower)]; h }
16
- end
17
-
18
- def self.to_hash_attrs
19
- EVENT_TYPE_ATTRS
20
- end
21
-
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,21 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- class EventTypeResult < Api::BF::Data::Base
6
-
7
- attr_accessor :market_count,
8
- :event_type
9
-
10
- def self.from_json(json_row)
11
- new(
12
- event_type: Api::BF::Data::EventType.from_json(json_row['eventType']),
13
- market_count: json_row['marketCount'],
14
- )
15
- end
16
-
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,19 +0,0 @@
1
- module BetfairApiNgRails
2
- module Api
3
- module BF
4
- module Data
5
- class MarketFilter < Api::BF::Data::Base
6
- include Api::BF::Data::Attributes
7
- include Api::BF::Data::Concerns::Hashable
8
-
9
- attr_accessor *MARKET_FILTER_ATTRS
10
-
11
- def self.to_hash_attrs
12
- MARKET_FILTER_ATTRS
13
- end
14
-
15
- end
16
- end
17
- end
18
- end
19
- end