Class: WebinarJam::Client
- Inherits:
-
Object
- Object
- WebinarJam::Client
- Defined in:
- lib/webinarjam/client.rb
Overview
HTTP client for the WebinarJam / EverWebinar API.
Every endpoint is a POST with a form-encoded body and returns JSON,
except unsubscribe which returns 204 No Content.
Constant Summary collapse
- BASE_URL =
"https://api.webinarjam.com"- PRODUCTS =
%i[webinarjam everwebinar].freeze
Instance Attribute Summary collapse
-
#max_retries ⇒ Object
readonly
Returns the value of attribute max_retries.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
Instance Method Summary collapse
-
#countries ⇒ Hash
Retrieve the list of countries and states/provinces whose ids can be used in the country/state registration fields.
-
#initialize(api_key: ENV["WEBINARJAM_API_KEY"], product: :webinarjam, base_url: BASE_URL, open_timeout: 10, read_timeout: 30, max_retries: 0) ⇒ Client
constructor
A new instance of Client.
-
#register(webinar_id:, first_name:, email:, schedule:, **params) ⇒ Hash
Register a user to a webinar.
-
#registrants(webinar_id:, schedule_id:, **params) ⇒ Hash
Get a list of registrants and attendees for one webinar session.
-
#unsubscribe(webinar_id:, lead_id:) ⇒ true
Unsubscribe a lead from a webinar's notification queue.
-
#webinar(webinar_id) ⇒ Hash
Get details about one particular webinar.
-
#webinars ⇒ Hash
Retrieve the full list of webinars published in the account.
Constructor Details
#initialize(api_key: ENV["WEBINARJAM_API_KEY"], product: :webinarjam, base_url: BASE_URL, open_timeout: 10, read_timeout: 30, max_retries: 0) ⇒ Client
Returns a new instance of Client.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/webinarjam/client.rb', line 21 def initialize(api_key: ENV["WEBINARJAM_API_KEY"], product: :webinarjam, base_url: BASE_URL, open_timeout: 10, read_timeout: 30, max_retries: 0) if api_key.nil? || api_key.to_s.empty? raise ConfigurationError, "api_key is required (pass api_key: or set ENV[\"WEBINARJAM_API_KEY\"])" end product = product.to_sym raise ArgumentError, "product must be one of #{PRODUCTS.inspect}" unless PRODUCTS.include?(product) @api_key = api_key @product = product @base_url = base_url @open_timeout = open_timeout @read_timeout = read_timeout @max_retries = max_retries end |
Instance Attribute Details
#max_retries ⇒ Object (readonly)
Returns the value of attribute max_retries.
16 17 18 |
# File 'lib/webinarjam/client.rb', line 16 def max_retries @max_retries end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
16 17 18 |
# File 'lib/webinarjam/client.rb', line 16 def product @product end |
Instance Method Details
#countries ⇒ Hash
Retrieve the list of countries and states/provinces whose ids can be used in the country/state registration fields.
54 55 56 |
# File 'lib/webinarjam/client.rb', line 54 def countries post("countries") end |
#register(webinar_id:, first_name:, email:, schedule:, **params) ⇒ Hash
Register a user to a webinar.
Optional params include: last_name, country, state, timezone_id, ip_address, phone_country_code, phone, twilio_consent. EverWebinar additionally accepts date and timezone (e.g. "GMT-5"). Custom registration fields are passed by their label, as returned by #webinar.
65 66 67 68 69 |
# File 'lib/webinarjam/client.rb', line 65 def register(webinar_id:, first_name:, email:, schedule:, **params) post("register", params.merge( webinar_id: webinar_id, first_name: first_name, email: email, schedule: schedule )) end |
#registrants(webinar_id:, schedule_id:, **params) ⇒ Hash
Get a list of registrants and attendees for one webinar session.
Optional params include: attended_live, attended_replay, purchased, page, attended_live_timestamp, attended_replay_timestamp, date_range, search.
77 78 79 |
# File 'lib/webinarjam/client.rb', line 77 def registrants(webinar_id:, schedule_id:, **params) post("registrants", params.merge(webinar_id: webinar_id, schedule_id: schedule_id)) end |
#unsubscribe(webinar_id:, lead_id:) ⇒ true
Unsubscribe a lead from a webinar's notification queue.
83 84 85 86 |
# File 'lib/webinarjam/client.rb', line 83 def unsubscribe(webinar_id:, lead_id:) post("unsubscribe", webinar_id: webinar_id, lead_id: lead_id) true end |
#webinar(webinar_id) ⇒ Hash
Get details about one particular webinar.
47 48 49 |
# File 'lib/webinarjam/client.rb', line 47 def webinar(webinar_id) post("webinar", webinar_id: webinar_id) end |
#webinars ⇒ Hash
Retrieve the full list of webinars published in the account.
41 42 43 |
# File 'lib/webinarjam/client.rb', line 41 def webinars post("webinars") end |