betfair_api_ng_rails 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -1
  3. data/Rakefile +8 -8
  4. data/lib/betfair_api_ng_rails/api/connection.rb +3 -0
  5. data/lib/betfair_api_ng_rails/api/connection_ext/error_handling.rb +31 -0
  6. data/lib/betfair_api_ng_rails/api/connection_ext/formatting.rb +0 -1
  7. data/lib/betfair_api_ng_rails/api/connection_ext/parsing.rb +0 -1
  8. data/lib/betfair_api_ng_rails/api/data/base.rb +2 -1
  9. data/lib/betfair_api_ng_rails/api/data/competition.rb +7 -6
  10. data/lib/betfair_api_ng_rails/api/data/competition_result.rb +6 -10
  11. data/lib/betfair_api_ng_rails/api/data/concerns/attributable.rb +51 -0
  12. data/lib/betfair_api_ng_rails/api/data/concerns/hashable.rb +7 -2
  13. data/lib/betfair_api_ng_rails/api/data/concerns/jsonable.rb +46 -0
  14. data/lib/betfair_api_ng_rails/api/data/constants.rb +1 -1
  15. data/lib/betfair_api_ng_rails/api/data/country_code_result.rb +5 -8
  16. data/lib/betfair_api_ng_rails/api/data/event.rb +9 -4
  17. data/lib/betfair_api_ng_rails/api/data/event_result.rb +5 -8
  18. data/lib/betfair_api_ng_rails/api/data/event_type.rb +5 -4
  19. data/lib/betfair_api_ng_rails/api/data/event_type_result.rb +5 -8
  20. data/lib/betfair_api_ng_rails/api/data/ex_best_offers_overrides.rb +24 -0
  21. data/lib/betfair_api_ng_rails/api/data/exchange_prices.rb +16 -0
  22. data/lib/betfair_api_ng_rails/api/data/market_book.rb +31 -0
  23. data/lib/betfair_api_ng_rails/api/data/market_catalogue.rb +23 -0
  24. data/lib/betfair_api_ng_rails/api/data/market_description.rb +29 -0
  25. data/lib/betfair_api_ng_rails/api/data/market_filter.rb +18 -1
  26. data/lib/betfair_api_ng_rails/api/data/market_type_result.rb +5 -8
  27. data/lib/betfair_api_ng_rails/api/data/match.rb +19 -0
  28. data/lib/betfair_api_ng_rails/api/data/order.rb +29 -0
  29. data/lib/betfair_api_ng_rails/api/data/price_projection.rb +23 -0
  30. data/lib/betfair_api_ng_rails/api/data/price_size.rb +15 -0
  31. data/lib/betfair_api_ng_rails/api/data/runner.rb +24 -0
  32. data/lib/betfair_api_ng_rails/api/data/runner_catalog.rb +19 -0
  33. data/lib/betfair_api_ng_rails/api/data/starting_prices.rb +18 -0
  34. data/lib/betfair_api_ng_rails/api/data/time_range.rb +5 -4
  35. data/lib/betfair_api_ng_rails/api/data/time_range_result.rb +5 -8
  36. data/lib/betfair_api_ng_rails/api/data/venue_result.rb +5 -8
  37. data/lib/betfair_api_ng_rails/api/hashalator.rb +2 -1
  38. data/lib/betfair_api_ng_rails/api/parsers/base.rb +0 -2
  39. data/lib/betfair_api_ng_rails/api/parsers/list_market_book.rb +15 -0
  40. data/lib/betfair_api_ng_rails/api/parsers/list_market_catalogue.rb +15 -0
  41. data/lib/betfair_api_ng_rails/api/request_methods.rb +9 -1
  42. data/lib/betfair_api_ng_rails/errors.rb +7 -0
  43. data/lib/betfair_api_ng_rails/version.rb +1 -1
  44. data/lib/betfair_api_ng_rails.rb +41 -25
  45. data/spec/betfair_api_ng_rails/api/connection_spec.rb +3 -1
  46. data/spec/betfair_api_ng_rails/api/data/competition_result_spec.rb +15 -0
  47. data/spec/betfair_api_ng_rails/api/data/competition_spec.rb +7 -0
  48. data/spec/betfair_api_ng_rails/api/data/concerns/attributable_spec.rb +156 -0
  49. data/spec/betfair_api_ng_rails/api/data/concerns/hashable_spec.rb +44 -0
  50. data/spec/betfair_api_ng_rails/api/data/concerns/jsonable_spec.rb +170 -0
  51. data/spec/betfair_api_ng_rails/api/data/country_code_result_spec.rb +7 -0
  52. data/spec/betfair_api_ng_rails/api/data/event_result_spec.rb +16 -0
  53. data/spec/betfair_api_ng_rails/api/data/event_spec.rb +7 -0
  54. data/spec/betfair_api_ng_rails/api/data/event_type_result_spec.rb +16 -0
  55. data/spec/betfair_api_ng_rails/api/data/event_type_spec.rb +7 -0
  56. data/spec/betfair_api_ng_rails/api/data/ex_best_offers_overrides_spec.rb +7 -0
  57. data/spec/betfair_api_ng_rails/api/data/exchange_prices_spec.rb +15 -0
  58. data/spec/betfair_api_ng_rails/api/data/market_book_spec.rb +15 -0
  59. data/spec/betfair_api_ng_rails/api/data/market_catalogue_spec.rb +39 -0
  60. data/spec/betfair_api_ng_rails/api/data/market_description_spec.rb +7 -0
  61. data/spec/betfair_api_ng_rails/api/data/market_filter_spec.rb +7 -0
  62. data/spec/betfair_api_ng_rails/api/data/market_type_result_spec.rb +7 -0
  63. data/spec/betfair_api_ng_rails/api/data/match_spec.rb +7 -0
  64. data/spec/betfair_api_ng_rails/api/data/order_spec.rb +7 -0
  65. data/spec/betfair_api_ng_rails/api/data/price_projection_spec.rb +15 -0
  66. data/spec/betfair_api_ng_rails/api/data/price_size_spec.rb +7 -0
  67. data/spec/betfair_api_ng_rails/api/data/runner_catalog_spec.rb +7 -0
  68. data/spec/betfair_api_ng_rails/api/data/runner_spec.rb +33 -0
  69. data/spec/betfair_api_ng_rails/api/data/starting_prices_spec.rb +7 -0
  70. data/spec/betfair_api_ng_rails/api/data/time_range_result_spec.rb +17 -0
  71. data/spec/betfair_api_ng_rails/api/data/time_range_spec.rb +7 -0
  72. data/spec/betfair_api_ng_rails/api/data/venue_result_spec.rb +7 -0
  73. data/spec/betfair_api_ng_rails/api/hashalator_spec.rb +34 -4
  74. data/spec/betfair_api_ng_rails/api/request_methods_spec.rb +20 -0
  75. data/spec/betfair_api_ng_rails/integration/list_market_book_spec.rb +19 -0
  76. data/spec/betfair_api_ng_rails/integration/list_market_catalogue_spec.rb +36 -0
  77. data/spec/support/base_yaml_loader.rb +21 -0
  78. data/spec/support/data/models.yml +205 -0
  79. data/spec/support/data_models_yaml_loader.rb +7 -0
  80. data/spec/support/helper.rb +9 -0
  81. data/spec/support/shared_examples/data_model.rb +35 -0
  82. data/spec/support/shared_examples/simple_list_filtering_request.rb +3 -1
  83. metadata +100 -18
  84. data/lib/betfair_api_ng_rails/api/data/attributes.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c20bda2211a6be34fbfffba46eb548faf580d3a3
4
- data.tar.gz: 81c228df7a738da9bc5156485567ea34ab566820
3
+ metadata.gz: 3a846cee18d46f60c19a677111624b07cb5673ce
4
+ data.tar.gz: 5bbef065b3ef31d43d789d1daef6e347aa4d4678
5
5
  SHA512:
6
- metadata.gz: a08183228cab41b7d28a52cc86328cdba3fcedc80a5aec045cf752810aa825ea8b1fc66c35a92dd71f2f008169592596e53bb295d8342232aa53ab74fdd451d4
7
- data.tar.gz: 20693a5383bb7bcceb79d35977090acda984cd3327498c47160528dcadc2a98c438ba91fe8645bebc795f7b9a16fd143b8de5afe658e3df6eb855902ef9db9a3
6
+ metadata.gz: 8be49808b5673fc0dfd9aebfb786743d2749703d07adbd5de2ae171c518a1bd825c2d5a1af971e675a1e5af7f2d27034d96d7248022b13e1bceedb9b275d1bed
7
+ data.tar.gz: ed938a79784a41ddb3fff8dd18550d6b98c7b21bed9af4922eb2e67c1be180cd3c544559b789d13c893728a92fe0a65558e1349d4a989da9ef2a3f635f0468aa
data/README.md CHANGED
@@ -35,7 +35,14 @@ In this files you must specify credentials to API-NG. Also you should notice tha
35
35
 
36
36
  ## Usage
37
37
 
38
- Please check [wiki pages](https://github.com/alterego-labs/betfair_api_ng_rails/wiki). It will be available soon...
38
+ Please check [wiki pages](https://github.com/alterego-labs/betfair_api_ng_rails/wiki).
39
+
40
+ ## CHANGES IN 1.1.0
41
+
42
+ 1. Supporting all [Simple listing filtered requests](https://github.com/alterego-labs/betfair_api_ng_rails/wiki/Simple-listing-filtered-requests)
43
+ 2. Supporting **listMarketCatalogue** and **listMarketBook** methods
44
+ 3. Raising APINGException if error occurred similar official API-NG
45
+ 4. Refactoring and testing
39
46
 
40
47
  ## CHANGES IN 1.0.0
41
48
 
@@ -51,6 +58,10 @@ Please check [wiki pages](https://github.com/alterego-labs/betfair_api_ng_rails/
51
58
  4. Added shortcuts for models
52
59
  5. Refactoring
53
60
 
61
+ ## Specs
62
+
63
+ You may running all specs by `rspec spec --color` to be sure that all is alright.
64
+
54
65
  ## Contributing
55
66
 
56
67
  1. Fork it
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
1
  require "rubygems"
2
- require 'rspec/core/rake_task'
3
- require 'rubygems/specification'
2
+ # require 'rspec/core/rake_task'
3
+ # require 'rubygems/specification'
4
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
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
@@ -1,3 +1,5 @@
1
+ require "betfair_api_ng_rails/errors"
2
+
1
3
  module BetfairApiNgRails
2
4
  module Api
3
5
  class Connection
@@ -12,6 +14,7 @@ module BetfairApiNgRails
12
14
  provider.fetch method: method, params: hashing(params)
13
15
  end
14
16
 
17
+ include Api::ConnectionExt::ErrorHandling
15
18
  include Api::ConnectionExt::Parsing
16
19
  include Api::ConnectionExt::Formatting
17
20
 
@@ -0,0 +1,31 @@
1
+ require 'active_support/inflector'
2
+ require "betfair_api_ng_rails/errors"
3
+
4
+ module BetfairApiNgRails
5
+ module Api
6
+ module ConnectionExt
7
+ module ErrorHandling
8
+ include BetfairApiNgRails::Api::Constants
9
+
10
+ def self.included(base)
11
+ base.send :class_eval, <<-CODE
12
+ def request_with_error_handling(method, params = {})
13
+ res = request_without_error_handling(method, params)
14
+ raise_exception(res.error_info) if res.has_error?
15
+ res
16
+ end
17
+ alias_method :request_without_error_handling, :request
18
+ alias_method :request, :request_with_error_handling
19
+ CODE
20
+ end
21
+
22
+ private
23
+
24
+ def raise_exception(error)
25
+ raise BetfairApiNgRails::APINGException.new(error), "Error in #{error[:type]} section"
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,5 +1,4 @@
1
1
  require 'active_support/inflector'
2
- require 'pry-nav'
3
2
 
4
3
  module BetfairApiNgRails
5
4
  module Api
@@ -1,5 +1,4 @@
1
1
  require 'active_support/inflector'
2
- require 'pry-nav'
3
2
 
4
3
  module BetfairApiNgRails
5
4
  module Api
@@ -4,7 +4,8 @@ module BetfairApiNgRails
4
4
  module Api
5
5
  module Data
6
6
  class Base
7
- include Api::Data::Attributes
7
+ include Api::Data::Concerns::Attributable
8
+ include Api::Data::Concerns::Jsonable
8
9
 
9
10
  def initialize(args = {})
10
11
  args.each { |attribute, value| self.send("#{attribute}=", value) }
@@ -4,12 +4,13 @@ module BetfairApiNgRails
4
4
  class Competition < Api::Data::Base
5
5
  include Api::Data::Concerns::Hashable
6
6
 
7
- attr_accessor *COMPETITION_ATTRS
8
-
9
- def self.from_json(json_row)
10
- new COMPETITION_ATTRS.inject({}) { |h, a| h[a] = json_row[a.to_s.camelize(:lower)]; h }
11
- end
12
-
7
+ COMPETITION_ATTRS = [
8
+ :id,
9
+ :name
10
+ ]
11
+
12
+ attributes COMPETITION_ATTRS
13
+
13
14
  def self.to_hash_attrs
14
15
  COMPETITION_ATTRS
15
16
  end
@@ -3,17 +3,13 @@ module BetfairApiNgRails
3
3
  module Data
4
4
  class CompetitionResult < Api::Data::Base
5
5
 
6
- attr_accessor :market_count,
7
- :competition_region,
8
- :competition
6
+ COMPETITION_RESULT_ATTRS = [
7
+ :market_count,
8
+ :competition_region,
9
+ {competition: {type: BetfairApiNgRails::Competition} }
10
+ ]
9
11
 
10
- def self.from_json(json_row)
11
- new(
12
- competition: Api::Data::Competition.from_json(json_row['competition']),
13
- market_count: json_row['marketCount'],
14
- competition_region: json_row['competitionRegion']
15
- )
16
- end
12
+ attributes COMPETITION_RESULT_ATTRS
17
13
 
18
14
  end
19
15
  end
@@ -0,0 +1,51 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ module Concerns
5
+ module Attributable
6
+
7
+ DEFAULT_OPTIONS = { type: String, array: false }
8
+
9
+ def self.included(base)
10
+ base.send :extend, ClassMethods
11
+ end
12
+
13
+ module ClassMethods
14
+
15
+ def attributes(attrs)
16
+ define_class_attrs attrs
17
+ define_attr_accessors
18
+ end
19
+
20
+ private
21
+
22
+ def define_class_attrs(attrs)
23
+ class << self; attr_accessor :class_attrs; end
24
+ self.class_attrs = process_attributes(attrs)
25
+ end
26
+
27
+ def process_attributes(attrs)
28
+ attrs.each_with_object({}) do |a, h|
29
+ h[fetch_attr_name(a)] = fetch_attr_options(a)
30
+ end
31
+ end
32
+
33
+ def define_attr_accessors
34
+ self.class_attrs.each { |name, options| class_eval("attr_accessor :#{name}") }
35
+ end
36
+
37
+ def fetch_attr_name(attrib)
38
+ attrib.is_a?(Hash) ? attrib.keys.first : attrib
39
+ end
40
+
41
+ def fetch_attr_options(attrib)
42
+ attrib.is_a?(Hash) ? DEFAULT_OPTIONS.merge(attrib.values.first) : DEFAULT_OPTIONS
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -13,8 +13,9 @@ module BetfairApiNgRails
13
13
 
14
14
  def attributes_hash
15
15
  self.class.to_hash_attrs.each_with_object({}) do |a, h|
16
- val = get_attr_value(a)
17
- h[a] = val unless val.nil?
16
+ key = get_attr_key(a)
17
+ val = get_attr_value(key)
18
+ h[get_attr_key(key)] = val unless val.nil?
18
19
  end
19
20
  end
20
21
 
@@ -22,6 +23,10 @@ module BetfairApiNgRails
22
23
  self.send attrib
23
24
  end
24
25
 
26
+ def get_attr_key(attrib)
27
+ attrib.is_a?(Hash) ? attrib.keys.first : attrib
28
+ end
29
+
25
30
  end
26
31
  end
27
32
  end
@@ -0,0 +1,46 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ module Concerns
5
+ module Jsonable
6
+
7
+ def self.included(base)
8
+ base.send :extend, ClassMethods
9
+ end
10
+
11
+ module ClassMethods
12
+
13
+ def from_json(data = {})
14
+ return nil unless self.respond_to?(:class_attrs)
15
+ self.new set_attributes(data)
16
+ end
17
+
18
+ private
19
+
20
+ def set_attributes(data)
21
+ self.class_attrs.each_with_object({}) do |(name, options), h|
22
+ h[name] = get_attr_value(data, name, options)
23
+ end
24
+ end
25
+
26
+ def json_key(attrib)
27
+ attrib.to_s.camelize(:lower)
28
+ end
29
+
30
+ def get_attr_value(data, name, options)
31
+ j_data = data[json_key(name)]
32
+ return nil unless j_data
33
+ options[:array] ? j_data.map { |r| prepare_value(options[:type], r) } : prepare_value(options[:type], j_data)
34
+ end
35
+
36
+ def prepare_value(type, data)
37
+ type == String ? data : type.from_json(data)
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -3,7 +3,7 @@ module BetfairApiNgRails
3
3
  module Data
4
4
  module Constants
5
5
 
6
- ATTRS_AS_IS = [Hash, String, Symbol, Fixnum]
6
+ ATTRS_AS_IS = [Hash, String, Symbol, Fixnum, NilClass]
7
7
 
8
8
  end
9
9
  end
@@ -3,15 +3,12 @@ module BetfairApiNgRails
3
3
  module Data
4
4
  class CountryCodeResult < Api::Data::Base
5
5
 
6
- attr_accessor :market_count,
7
- :country_code
6
+ COUNTRY_CODE_RESULT_ATTRS = [
7
+ :market_count,
8
+ :country_code
9
+ ]
8
10
 
9
- def self.from_json(json_row)
10
- new(
11
- country_code: json_row['countryCode'],
12
- market_count: json_row['marketCount']
13
- )
14
- end
11
+ attributes COUNTRY_CODE_RESULT_ATTRS
15
12
 
16
13
  end
17
14
  end
@@ -4,11 +4,16 @@ module BetfairApiNgRails
4
4
  class Event < Api::Data::Base
5
5
  include Api::Data::Concerns::Hashable
6
6
 
7
- attr_accessor *EVENT_ATTRS
7
+ EVENT_ATTRS = [
8
+ :id,
9
+ :name,
10
+ :timezone,
11
+ :country_code,
12
+ :venue,
13
+ :open_date
14
+ ]
8
15
 
9
- def self.from_json(json_row)
10
- new EVENT_ATTRS.inject({}) { |h, a| h[a] = json_row[a.to_s.camelize(:lower)]; h }
11
- end
16
+ attributes EVENT_ATTRS
12
17
 
13
18
  def self.to_hash_attrs
14
19
  EVENT_ATTRS
@@ -3,15 +3,12 @@ module BetfairApiNgRails
3
3
  module Data
4
4
  class EventResult < Api::Data::Base
5
5
 
6
- attr_accessor :market_count,
7
- :event
6
+ EVENT_RESULT_ATTRS = [
7
+ :market_count,
8
+ {event: { type: BetfairApiNgRails::Event }}
9
+ ]
8
10
 
9
- def self.from_json(json_row)
10
- new(
11
- event: Api::Data::Event.from_json(json_row['event']),
12
- market_count: json_row['marketCount']
13
- )
14
- end
11
+ attributes EVENT_RESULT_ATTRS
15
12
 
16
13
  end
17
14
  end
@@ -4,11 +4,12 @@ module BetfairApiNgRails
4
4
  class EventType < Api::Data::Base
5
5
  include Api::Data::Concerns::Hashable
6
6
 
7
- attr_accessor *EVENT_TYPE_ATTRS
7
+ EVENT_TYPE_ATTRS = [
8
+ :id,
9
+ :name
10
+ ]
8
11
 
9
- def self.from_json(json_row)
10
- new EVENT_TYPE_ATTRS.inject({}) { |h, a| h[a] = json_row[a.to_s.camelize(:lower)]; h }
11
- end
12
+ attributes EVENT_TYPE_ATTRS
12
13
 
13
14
  def self.to_hash_attrs
14
15
  EVENT_TYPE_ATTRS
@@ -3,15 +3,12 @@ module BetfairApiNgRails
3
3
  module Data
4
4
  class EventTypeResult < Api::Data::Base
5
5
 
6
- attr_accessor :market_count,
7
- :event_type
6
+ EVENT_TYPE_RESULT_ATTRS = [
7
+ :market_count,
8
+ {event_type: {type: BetfairApiNgRails::EventType}}
9
+ ]
8
10
 
9
- def self.from_json(json_row)
10
- new(
11
- event_type: Api::Data::EventType.from_json(json_row['eventType']),
12
- market_count: json_row['marketCount']
13
- )
14
- end
11
+ attributes EVENT_TYPE_RESULT_ATTRS
15
12
 
16
13
  end
17
14
  end
@@ -0,0 +1,24 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ class ExBestOffersOverrides < Api::Data::Base
5
+ include Api::Data::Concerns::Hashable
6
+
7
+ EX_BEST_OFFERS_OVERRIDES_ATTRS = [
8
+ :best_prices_depth,
9
+ :rollup_model,
10
+ :rollup_limit,
11
+ :rollup_liability_threshold,
12
+ :rollup_liability_factor
13
+ ]
14
+
15
+ attributes EX_BEST_OFFERS_OVERRIDES_ATTRS
16
+
17
+ def self.to_hash_attrs
18
+ EX_BEST_OFFERS_OVERRIDES_ATTRS
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ class ExchangePrices < Api::Data::Base
5
+
6
+ EXCHANGE_PRICES_ATTRS = [
7
+ {available_to_back: { type: BetfairApiNgRails::PriceSize, array: true }},
8
+ {available_to_lay: { type: BetfairApiNgRails::PriceSize, array: true }},
9
+ {traded_volume: { type: BetfairApiNgRails::PriceSize, array: true }}
10
+ ]
11
+
12
+ attributes EXCHANGE_PRICES_ATTRS
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ class MarketBook < Api::Data::Base
5
+
6
+ MARKET_BOOK_ATTRS = [
7
+ :market_id,
8
+ :is_market_data_delayed,
9
+ :status,
10
+ :bet_delay,
11
+ :bsp_reconciled,
12
+ :complete,
13
+ :inplay,
14
+ :number_of_runners,
15
+ :number_of_winners,
16
+ :number_of_active_runners,
17
+ :last_match_time,
18
+ :total_matched,
19
+ :total_available,
20
+ :cross_matching,
21
+ :runners_voidable,
22
+ :version,
23
+ {runners: { type: BetfairApiNgRails::Runner, array: true }}
24
+ ]
25
+
26
+ attributes MARKET_BOOK_ATTRS
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ class MarketCatalogue < Api::Data::Base
5
+
6
+ MARKET_CATALOGUE_ATTRS = [
7
+ :market_id,
8
+ :market_name,
9
+ :market_start_time,
10
+ :total_matched,
11
+ {description: { type: BetfairApiNgRails::MarketDescription }},
12
+ {runners: { type: BetfairApiNgRails::RunnerCatalog, array: true }},
13
+ {event_type: { type: BetfairApiNgRails::EventType }},
14
+ {competition: { type: BetfairApiNgRails::Competition }},
15
+ {event: { type: BetfairApiNgRails::Event }}
16
+ ]
17
+
18
+ attributes MARKET_CATALOGUE_ATTRS
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ class MarketDescription < Api::Data::Base
5
+
6
+ MARKET_DESCRIPTION_ATTRS = [
7
+ :persistence_enabled,
8
+ :bsp_market,
9
+ :market_time,
10
+ :suspend_time,
11
+ :settle_time,
12
+ :betting_type,
13
+ :turn_in_play_enabled,
14
+ :market_type,
15
+ :regulator,
16
+ :market_base_rate,
17
+ :discount_allowed,
18
+ :wallet,
19
+ :rules,
20
+ :rules_has_date,
21
+ :clarifications
22
+ ]
23
+
24
+ attributes MARKET_DESCRIPTION_ATTRS
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -4,7 +4,24 @@ module BetfairApiNgRails
4
4
  class MarketFilter < Api::Data::Base
5
5
  include Api::Data::Concerns::Hashable
6
6
 
7
- attr_accessor *MARKET_FILTER_ATTRS
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
+ attributes MARKET_FILTER_ATTRS
8
25
 
9
26
  def self.to_hash_attrs
10
27
  MARKET_FILTER_ATTRS
@@ -3,15 +3,12 @@ module BetfairApiNgRails
3
3
  module Data
4
4
  class MarketTypeResult < Api::Data::Base
5
5
 
6
- attr_accessor :market_count,
7
- :market_type
6
+ MARKET_TYPE_RESULT_ATTRS = [
7
+ :market_count,
8
+ :market_type
9
+ ]
8
10
 
9
- def self.from_json(json_row)
10
- new(
11
- market_type: json_row['marketType'],
12
- market_count: json_row['marketCount']
13
- )
14
- end
11
+ attributes MARKET_TYPE_RESULT_ATTRS
15
12
 
16
13
  end
17
14
  end
@@ -0,0 +1,19 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ class Match < Api::Data::Base
5
+
6
+ MATCH_ATTRS = [
7
+ :bet_id,
8
+ :match_id,
9
+ :side,
10
+ :price,
11
+ :size,
12
+ :match_date
13
+ ]
14
+
15
+ attributes MATCH_ATTRS
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ class Order < Api::Data::Base
5
+
6
+ ORDER_ATTRS = [
7
+ :bet_id,
8
+ :order_type,
9
+ :status,
10
+ :persistence_type,
11
+ :side,
12
+ :price,
13
+ :size,
14
+ :bsp_liability,
15
+ :placed_date,
16
+ :avg_price_matched,
17
+ :size_matched,
18
+ :size_remaining,
19
+ :size_lapsed,
20
+ :size_cancelled,
21
+ :size_voided
22
+ ]
23
+
24
+ attributes ORDER_ATTRS
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ module BetfairApiNgRails
2
+ module Api
3
+ module Data
4
+ class PriceProjection < Api::Data::Base
5
+ include Api::Data::Concerns::Hashable
6
+
7
+ PRICE_PROJECTION_ATTRS = [
8
+ :price_data,
9
+ {ex_best_offers_overrides: { type: BetfairApiNgRails::ExBestOffersOverrides }},
10
+ :virtualise,
11
+ :rollover_stakes
12
+ ]
13
+
14
+ attributes PRICE_PROJECTION_ATTRS
15
+
16
+ def self.to_hash_attrs
17
+ PRICE_PROJECTION_ATTRS
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end