-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adds the rest of the polymarket endpoints #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3c9b3ed
feat: adds Orderbook endpoint
bougyman 604bc89
refactor: added Listable module to dry up the #list methods
bougyman 1615c85
feat: adds the rest of the polymarket endpoints
bougyman 1001e13
test: gets everything to 100% branch coverage
bougyman 5303a22
ci: updates workflow to include simplecov check
bougyman a381551
test: corrected Endpoint spec to ensure Polymarket::Client is used
bougyman e837d6a
ci: moves simplecov into validations
bougyman 146b334
ci: makes coverage.yaml its own job
bougyman 28908e0
ci: trying to get coverage right
bougyman 9587452
ci: corrects coverage conditional
bougyman 24a5c19
ci: uses hashFiles to check file existence
bougyman 9e41a7b
ci: adds tmate action to debug coverage problems
bougyman f630cbf
ci: puts coverage files in the correct directory
bougyman bb54c40
ci: include-hidden-files to get the .last_run.json to upload/download
bougyman 3f18274
ci: removes tmate debugging step
bougyman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Rubyists | ||
| module Domeapi | ||
| module Polymarket | ||
| # Activity API endpoints | ||
| class Activity < Endpoint | ||
| include Listable | ||
|
|
||
| polymarket_path 'activity' | ||
|
|
||
| # Filter for activity | ||
| class Filter < Contract | ||
| Properties = Struct.new( | ||
| :user, | ||
| :start_time, | ||
| :end_time, | ||
| :market_slug, | ||
| :condition_id, | ||
| :limit, | ||
| :offset, | ||
| keyword_init: true | ||
| ) | ||
|
|
||
| Properties.members.each { |member| property member, populator: ->(value:, **) { value || skip! } } | ||
|
|
||
| validation do | ||
| params do | ||
| required(:user).filled(:string) | ||
| optional(:start_time).maybe(:integer) | ||
| optional(:end_time).maybe(:integer) | ||
| optional(:market_slug).maybe(:string) | ||
| optional(:condition_id).maybe(:string) | ||
| optional(:limit).maybe(:integer, gteq?: 1, lteq?: 1000) | ||
| optional(:offset).maybe(:integer, gteq?: 0) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Rubyists | ||
| module Domeapi | ||
| module Polymarket | ||
| # Mixin for listable resources | ||
| module Listable | ||
| def self.included(base) | ||
| base.extend(ClassMethods) | ||
| end | ||
|
|
||
| # Class methods for Listable | ||
| module ClassMethods | ||
| attr_accessor :endpoint_path | ||
|
|
||
| # Set the endpoint path for the resource | ||
| # | ||
| # @param path [String] API endpoint path | ||
| # | ||
| # @return [String] endpoint path | ||
| def polymarket_path(path) | ||
| self.endpoint_path = path | ||
| end | ||
| end | ||
|
|
||
| # List resources | ||
| # | ||
| # @param filter [Filter|Hash] Filter options | ||
| # | ||
| # @return [Hash|Array] resource data | ||
| def list(filter = self.class::Filter.new(self.class::Filter::Properties.new)) | ||
| filter = self.class::Filter.new(self.class::Filter::Properties.new(**filter)) if filter.is_a?(Hash) | ||
| raise ArgumentError, filter.errors.full_messages.join(', ') unless filter.validate({}) | ||
|
|
||
| client.get(self.class.endpoint_path, params: filter.to_h) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Rubyists | ||
| module Domeapi | ||
| module Polymarket | ||
| # Market Price API endpoints | ||
| class MarketPrice < Endpoint | ||
| include Listable | ||
|
|
||
| polymarket_path 'markets/get_market_price' | ||
|
|
||
| # Filter for market price | ||
| class Filter < Contract | ||
| Properties = Struct.new( | ||
| :token_id, | ||
| :at_time, | ||
| keyword_init: true | ||
| ) | ||
|
|
||
| Properties.members.each { |member| property member, populator: ->(value:, **) { value || skip! } } | ||
|
|
||
| validation do | ||
| params do | ||
| required(:token_id).filled(:string) | ||
| optional(:at_time).maybe(:integer) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Rubyists | ||
| module Domeapi | ||
| module Polymarket | ||
| # Orderbook API endpoints | ||
| class Orderbook | ||
bougyman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| include Listable | ||
|
|
||
| polymarket_path 'markets/get_orderbook_history' | ||
|
|
||
| attr_reader :client | ||
|
|
||
| # @param client [Rubyists::Domeapi::Polymarket::Client] | ||
| # | ||
| # @return [void] | ||
| def initialize(client = Rubyists::Domeapi::Polymarket::Client.new) | ||
| @client = client | ||
| end | ||
|
|
||
bougyman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Filter for orderbook history | ||
| class Filter < Contract | ||
| Properties = Struct.new( | ||
| :token_id, | ||
| :start_time, | ||
| :end_time, | ||
| :limit, | ||
| :offset, | ||
| keyword_init: true | ||
| ) | ||
|
|
||
| Properties.members.each { |member| property member, populator: ->(model:, **) { model || skip! } } | ||
bougyman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| validation do | ||
| params do | ||
| required(:token_id).filled(:string) | ||
| required(:start_time).filled(:integer) | ||
| required(:end_time).filled(:integer) | ||
| optional(:limit).maybe(:integer, gteq?: 1, lteq?: 1000) | ||
| optional(:offset).maybe(:integer, gteq?: 0) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # Get orderbook history | ||
| # | ||
| # @param filter [Filter] Filter options | ||
| # | ||
| # @return [Hash] orderbook history data | ||
| # def list(filter = Filter.new(Filter::Properties.new)) | ||
| # filter = Filter.new(Filter::Properties.new(**filter)) if filter.is_a?(Hash) | ||
| # raise ArgumentError, filter.errors.full_messages.join(', ') unless filter.validate({}) | ||
| # | ||
| # client.get('markets/get_orderbook_history', params: filter.to_h) | ||
| # end | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.