Class: Ashby::Offers
Overview
Ashby::Offers provides access to offer-related endpoints in the Ashby API.
Supports fetching all offers with pagination and retrieving a specific offer by ID.
Example:
Ashby::Offers.all
Ashby::Offers.find(id: 'offer_xyz789')
Constant Summary
Constants inherited from Client
Class Method Summary collapse
-
.all ⇒ Object
Fetches all offers with pagination support.
-
.find(id: nil) ⇒ Object
Finds an offer by its Ashby ID.
- .most_recent_offer_by_application_id(application_id: nil) ⇒ Object
- .offers_by_application_id(application_id: nil) ⇒ Object
Methods inherited from Client
build_url, headers, paginated_post, post
Class Method Details
.all ⇒ Object
Fetches all offers with pagination support
14 15 16 |
# File 'lib/ashby/offers.rb', line 14 def self.all paginated_post('offer.list') end |
.find(id: nil) ⇒ Object
Finds an offer by its Ashby ID
19 20 21 22 23 24 25 |
# File 'lib/ashby/offers.rb', line 19 def self.find(id: nil) raise ArgumentError, 'Offer ID is required' if id.to_s.strip.empty? payload = { id: id } response = post('offer.info', payload) response['results'] end |
.most_recent_offer_by_application_id(application_id: nil) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ashby/offers.rb', line 35 def self.most_recent_offer_by_application_id(application_id: nil) raise ArgumentError, 'Application ID is required' if application_id.to_s.strip.empty? payload = { applicationId: application_id } response = post('offer.list', payload) response['results'].max_by { |o| o['latestVersion']['createdAt'] } end |
.offers_by_application_id(application_id: nil) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ashby/offers.rb', line 27 def self.offers_by_application_id(application_id: nil) raise ArgumentError, 'Application ID is required' if application_id.to_s.strip.empty? payload = { applicationId: application_id } response = post('offer.list', payload) response['results'] end |