Class: Repro::Api::Client
- Inherits:
-
Object
- Object
- Repro::Api::Client
- Defined in:
- lib/repro/api/client.rb,
lib/repro/api/client/version.rb
Constant Summary collapse
- API_VERSION =
'v1'.freeze
- API_ENDPOINT =
"https://marketing.repro.io/#{API_VERSION}".freeze
- VERSION =
"0.3.2"
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #endpoint ⇒ Object
-
#initialize(token, opts = {}) ⇒ Client
constructor
A new instance of Client.
-
#push_deliver(push_id, user_ids, opts = {}) ⇒ Object
/push/:push_id/deliver.
- #token ⇒ Object
- #user_agent ⇒ Object
Constructor Details
#initialize(token, opts = {}) ⇒ Client
Returns a new instance of Client.
17 18 19 |
# File 'lib/repro/api/client.rb', line 17 def initialize(token, opts = {}) @options = opts.merge(token: token, method: 'post') end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/repro/api/client.rb', line 15 def @options end |
Instance Method Details
#endpoint ⇒ Object
47 48 49 |
# File 'lib/repro/api/client.rb', line 47 def endpoint @options[:endpoint] || API_ENDPOINT end |
#push_deliver(push_id, user_ids, opts = {}) ⇒ Object
/push/:push_id/deliver
30 31 32 33 34 35 36 37 |
# File 'lib/repro/api/client.rb', line 30 def push_deliver(push_id, user_ids, opts = {}) raise ArgumentError, ':body is required.' unless opts[:body] opts[:path] = "/push/#{push_id}/deliver" body = { audience: { user_ids: user_ids } } body[:notification] = {custom_payload: build_payload(opts)} opts[:body] = body send_request(opts) end |
#token ⇒ Object
39 40 41 |
# File 'lib/repro/api/client.rb', line 39 def token @options[:token] end |
#user_agent ⇒ Object
43 44 45 |
# File 'lib/repro/api/client.rb', line 43 def user_agent @options[:user_agent] || "Repro Ruby Client/#{VERSION}" end |