prizepicks 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 +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +31 -13
- data/lib/prizepicks/api/endpoints/entries.rb +7 -1
- data/lib/prizepicks/api/endpoints/leagues.rb +15 -0
- data/lib/prizepicks/api/endpoints/projections.rb +15 -0
- data/lib/prizepicks/api/endpoints/sign_in.rb +6 -1
- data/lib/prizepicks/api/endpoints.rb +4 -0
- data/lib/prizepicks/api/responses/user.rb +23 -0
- data/lib/prizepicks/client.rb +4 -2
- data/lib/prizepicks/collection.rb +20 -0
- data/lib/prizepicks/error.rb +4 -0
- data/lib/prizepicks/faraday/connection.rb +1 -1
- data/lib/prizepicks/objects/base.rb +26 -0
- data/lib/prizepicks/objects/entry.rb +5 -0
- data/lib/prizepicks/objects/league.rb +5 -0
- data/lib/prizepicks/objects/projection.rb +5 -0
- data/lib/prizepicks/objects/user.rb +5 -0
- data/lib/prizepicks/version.rb +1 -1
- data/lib/prizepicks.rb +19 -10
- data/sig/prizepicks.rbs +1 -1
- metadata +15 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41d5091bcbfd11b34a1832b303f7682adf0a588fb780b036b6e826be05cea48d
|
4
|
+
data.tar.gz: f0f2f27500ed1cc7386be53cbdbec0fd80e494f4c7dad86bdad97a83d34c7030
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec535de7d275485a9330aa3c470dd80305f39b2303a84e286dc0b67e2e32c3ee5ae154a3b4b9bc42b8ffd1c93a05856d610b718724a30a4dd56bd0ade3d159bf
|
7
|
+
data.tar.gz: c312dc4c6e07ea7a17e110397328b0aea226c850e584dedefcc141a0c4d53c2b6fdc089b4b00ef28eec151dcdf9bc4be933afae2d52aa6694cd44572709ce0b2
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,31 +1,49 @@
|
|
1
|
-
|
1
|
+
PrizePicks Client
|
2
|
+
=================
|
2
3
|
|
3
|
-
|
4
|
+
[](https://badge.fury.io/rb/prizepicks)
|
5
|
+
[](https://github.com/troyizzle/prizepicks/actions/workflows/main.yml)
|
4
6
|
|
5
|
-
|
7
|
+
A client for PrizePicks API.
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
9
|
-
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
```ruby
|
13
|
+
gem 'prizepicks'
|
14
|
+
```
|
10
15
|
|
11
|
-
|
16
|
+
Add then execute:
|
12
17
|
|
13
|
-
|
18
|
+
`$ bundle install`
|
14
19
|
|
15
|
-
|
20
|
+
Or install it yourself as:
|
16
21
|
|
17
|
-
|
22
|
+
`$ gem install prizepicks`
|
18
23
|
|
19
24
|
## Usage
|
25
|
+
### Currently this only has fetching /entries
|
20
26
|
|
21
|
-
|
27
|
+
```
|
28
|
+
client = PrizePicks::Client.new({
|
29
|
+
email: example@example.com,
|
30
|
+
password: foobar
|
31
|
+
})
|
22
32
|
|
23
|
-
|
33
|
+
client.sign_in
|
34
|
+
client.entries
|
35
|
+
```
|
24
36
|
|
25
|
-
|
37
|
+
## Development
|
26
38
|
|
27
|
-
|
39
|
+
Run `bin/setup` to install dependencies. Then, run `rake test` to verify the test. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
40
|
|
29
41
|
## Contributing
|
30
42
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/troyizzle/prizepicks.
|
44
|
+
|
45
|
+
This project is early in progress, very early.
|
46
|
+
|
47
|
+
## License
|
48
|
+
|
49
|
+
This gem is available as open-source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -3,8 +3,14 @@ module PrizePicks
|
|
3
3
|
module Api
|
4
4
|
module Endpoints
|
5
5
|
module Entries
|
6
|
+
ENDPOINT = '/v1/entries'
|
7
|
+
|
6
8
|
def entries(options = {})
|
7
|
-
|
9
|
+
raise ArgumentError, 'email is required' unless @email
|
10
|
+
raise ArgumentError, 'password is required' unless @password
|
11
|
+
|
12
|
+
resp = request(:get, ENDPOINT, options)
|
13
|
+
Collection.from_response(resp, type: Entry)
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module PrizePicks
|
3
|
+
module Api
|
4
|
+
module Endpoints
|
5
|
+
module Leagues
|
6
|
+
ENDPOINT = '/v1/leagues'
|
7
|
+
|
8
|
+
def leagues(options = {})
|
9
|
+
resp = request(:get, ENDPOINT, options)
|
10
|
+
Collection.from_response(resp, type: League)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module PrizePicks
|
3
|
+
module Api
|
4
|
+
module Endpoints
|
5
|
+
module Projections
|
6
|
+
ENDPOINT = '/v1/projections'
|
7
|
+
|
8
|
+
def projections(options = {})
|
9
|
+
resp = request(:get, ENDPOINT, options)
|
10
|
+
Collection.from_response(resp, type: Projection)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,15 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module PrizePicks
|
3
4
|
module Api
|
4
5
|
module Endpoints
|
5
6
|
module SignIn
|
7
|
+
ENDPOINT = '/users/sign_in'
|
8
|
+
|
6
9
|
def sign_in
|
7
|
-
request(:post,
|
10
|
+
resp = request(:post, ENDPOINT, {
|
8
11
|
user: {
|
9
12
|
email: @email,
|
10
13
|
password: @password,
|
11
14
|
},
|
12
15
|
})
|
16
|
+
|
17
|
+
User.new(resp)
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'endpoints/entries'
|
4
|
+
require_relative 'endpoints/leagues'
|
5
|
+
require_relative 'endpoints/projections'
|
4
6
|
require_relative 'endpoints/sign_in'
|
5
7
|
|
6
8
|
module PrizePicks
|
7
9
|
module Api
|
8
10
|
module Endpoints
|
9
11
|
include Entries
|
12
|
+
include Leagues
|
13
|
+
include Projections
|
10
14
|
include SignIn
|
11
15
|
end
|
12
16
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module PrizePicks
|
3
|
+
module Api
|
4
|
+
module Responses
|
5
|
+
class User < OpenStruct
|
6
|
+
def initialize(attributes)
|
7
|
+
super to_obstruct(attributes)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_obstruct(_attributes)
|
11
|
+
case obj
|
12
|
+
when Hash
|
13
|
+
OpenStruct.new(obj.transform_values { |val| to_obstruct(val) })
|
14
|
+
when Array
|
15
|
+
obj.map { |o| to_obstruct(o) }
|
16
|
+
else
|
17
|
+
obj
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/prizepicks/client.rb
CHANGED
@@ -6,14 +6,16 @@ module PrizePicks
|
|
6
6
|
include Api::Endpoints
|
7
7
|
|
8
8
|
attr_accessor(*Config::ATTRIBUTES)
|
9
|
+
attr_reader :adapter
|
9
10
|
|
10
11
|
def initialize(options = {})
|
11
12
|
PrizePicks::Config::ATTRIBUTES.each do |key|
|
12
13
|
send("#{key}=", options.fetch(key, PrizePicks.config.send(key)))
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
# For testing
|
17
|
+
@stubs = options[:stubs] || nil
|
18
|
+
@adapter = options[:adapter] || nil
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module PrizePicks
|
3
|
+
class Collection
|
4
|
+
attr_reader :data, :total_pages, :current_page
|
5
|
+
|
6
|
+
def self.from_response(response, type:)
|
7
|
+
new(
|
8
|
+
data: response['data'].map { |attrs| type.new(attrs) },
|
9
|
+
current_page: response.dig('meta', 'current_page'),
|
10
|
+
total_pages: response.dig('meta', 'total_pages')
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(data:, current_page:, total_pages:)
|
15
|
+
@data = data
|
16
|
+
@current_page = current_page
|
17
|
+
@total_pages = total_pages
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module PrizePicks
|
5
|
+
class Base < OpenStruct
|
6
|
+
def initialize(resp)
|
7
|
+
@resp = resp
|
8
|
+
super to_obstruct(resp.dig('data', 'attributes'))
|
9
|
+
end
|
10
|
+
|
11
|
+
def data
|
12
|
+
@resp['data']
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_obstruct(obj)
|
16
|
+
case obj
|
17
|
+
when Hash
|
18
|
+
OpenStruct.new(obj.transform_values { |val| to_obstruct(val) })
|
19
|
+
when Array
|
20
|
+
obj.map { |o| to_obstruct(o) }
|
21
|
+
else
|
22
|
+
obj
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/prizepicks/version.rb
CHANGED
data/lib/prizepicks.rb
CHANGED
@@ -1,17 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'prizepicks/version'
|
4
|
-
require 'prizepicks/config'
|
5
|
-
|
6
2
|
require 'faraday'
|
7
3
|
require 'faraday-cookie_jar'
|
8
|
-
|
4
|
+
require 'prizepicks/version'
|
5
|
+
# require 'prizepicks/config'
|
9
6
|
require_relative 'prizepicks/faraday/connection'
|
10
7
|
require_relative 'prizepicks/faraday/request'
|
11
8
|
require_relative 'prizepicks/api/endpoints'
|
12
|
-
require_relative 'prizepicks/client'
|
9
|
+
# require_relative 'prizepicks/client'
|
10
|
+
|
11
|
+
module PrizePicks
|
12
|
+
autoload :Client, 'prizepicks/client'
|
13
|
+
autoload :Collection, 'prizepicks/collection'
|
14
|
+
autoload :Config, 'prizepicks/config'
|
15
|
+
autoload :Error, 'prizepicks/error'
|
16
|
+
|
17
|
+
# Responses
|
18
|
+
autoload :Responses, 'prizepicks/api/responses'
|
13
19
|
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
# Object
|
21
|
+
autoload :Base, 'prizepicks/objects/base'
|
22
|
+
autoload :Entry, 'prizepicks/objects/entry'
|
23
|
+
autoload :League, 'prizepicks/objects/league'
|
24
|
+
autoload :Projection, 'prizepicks/objects/projection'
|
25
|
+
autoload :User, 'prizepicks/objects/user'
|
26
|
+
end
|
data/sig/prizepicks.rbs
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prizepicks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Troy Underwood
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -102,6 +102,7 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- ".rubocop.yml"
|
105
|
+
- CHANGELOG.md
|
105
106
|
- Gemfile
|
106
107
|
- Gemfile.lock
|
107
108
|
- README.md
|
@@ -109,11 +110,21 @@ files:
|
|
109
110
|
- lib/prizepicks.rb
|
110
111
|
- lib/prizepicks/api/endpoints.rb
|
111
112
|
- lib/prizepicks/api/endpoints/entries.rb
|
113
|
+
- lib/prizepicks/api/endpoints/leagues.rb
|
114
|
+
- lib/prizepicks/api/endpoints/projections.rb
|
112
115
|
- lib/prizepicks/api/endpoints/sign_in.rb
|
116
|
+
- lib/prizepicks/api/responses/user.rb
|
113
117
|
- lib/prizepicks/client.rb
|
118
|
+
- lib/prizepicks/collection.rb
|
114
119
|
- lib/prizepicks/config.rb
|
120
|
+
- lib/prizepicks/error.rb
|
115
121
|
- lib/prizepicks/faraday/connection.rb
|
116
122
|
- lib/prizepicks/faraday/request.rb
|
123
|
+
- lib/prizepicks/objects/base.rb
|
124
|
+
- lib/prizepicks/objects/entry.rb
|
125
|
+
- lib/prizepicks/objects/league.rb
|
126
|
+
- lib/prizepicks/objects/projection.rb
|
127
|
+
- lib/prizepicks/objects/user.rb
|
117
128
|
- lib/prizepicks/version.rb
|
118
129
|
- sig/prizepicks.rbs
|
119
130
|
homepage: https://github.com/troyizzle/prizepicks
|
@@ -121,6 +132,7 @@ licenses: []
|
|
121
132
|
metadata:
|
122
133
|
homepage_uri: https://github.com/troyizzle/prizepicks
|
123
134
|
source_code_uri: https://github.com/troyizzle/prizepicks
|
135
|
+
changelog_uri: https://github.com/troyizzle/prizepicks/blob/master/CHANGELOG.md
|
124
136
|
post_install_message:
|
125
137
|
rdoc_options: []
|
126
138
|
require_paths:
|
@@ -136,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
148
|
- !ruby/object:Gem::Version
|
137
149
|
version: '0'
|
138
150
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
151
|
+
rubygems_version: 3.2.3
|
140
152
|
signing_key:
|
141
153
|
specification_version: 4
|
142
154
|
summary: PrizePicks client
|