Class: FiveMobilePush::Client
- Inherits:
-
Object
- Object
- FiveMobilePush::Client
- Defined in:
- lib/five_mobile_push/client.rb
Constant Summary collapse
- DEFAULT_ENDPOINT =
'https://push.fivemobile.com/rest'
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#api_token ⇒ Object
Returns the value of attribute api_token.
-
#application_uid ⇒ Object
Returns the value of attribute application_uid.
Class Method Summary collapse
-
.default_endpoint ⇒ URI
A URI object for the DEFAULT_ENDPOINT.
Instance Method Summary collapse
- #connection ⇒ Object
- #device(device_uid) ⇒ Object
- #get(path, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #notifier ⇒ Object
- #post(path, options = {}) ⇒ Object
- #tag(device_uid) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 |
# File 'lib/five_mobile_push/client.rb', line 11 def initialize(={}) self.application_uid = [:application_uid] || FiveMobilePush.application_uid self.api_token = [:api_token] || FiveMobilePush.api_token self.adapter = [:adapter] || FiveMobilePush.adapter end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/five_mobile_push/client.rb', line 9 def adapter @adapter end |
#api_token ⇒ Object
Returns the value of attribute api_token.
9 10 11 |
# File 'lib/five_mobile_push/client.rb', line 9 def api_token @api_token end |
#application_uid ⇒ Object
Returns the value of attribute application_uid.
9 10 11 |
# File 'lib/five_mobile_push/client.rb', line 9 def application_uid @application_uid end |
Class Method Details
.default_endpoint ⇒ URI
Returns a URI object for the DEFAULT_ENDPOINT.
46 47 48 |
# File 'lib/five_mobile_push/client.rb', line 46 def self.default_endpoint URI.parse(DEFAULT_ENDPOINT) end |
Instance Method Details
#connection ⇒ Object
18 19 20 21 22 23 |
# File 'lib/five_mobile_push/client.rb', line 18 def connection @connection ||= Faraday.new(:url => DEFAULT_ENDPOINT, :user_agent => 'FiveMobilePush Ruby gem') do |builder| builder.adapter self.adapter builder.use Faraday::Response::Errors end end |
#device(device_uid) ⇒ Object
33 34 35 |
# File 'lib/five_mobile_push/client.rb', line 33 def device(device_uid) FiveMobilePush::Device.new(self, device_uid) end |
#get(path, options = {}) ⇒ Object
25 26 27 |
# File 'lib/five_mobile_push/client.rb', line 25 def get(path, ={}) perform_request(:get, path, ) end |
#notifier ⇒ Object
37 38 39 |
# File 'lib/five_mobile_push/client.rb', line 37 def notifier FiveMobilePush::Notifier.new(self) end |
#post(path, options = {}) ⇒ Object
29 30 31 |
# File 'lib/five_mobile_push/client.rb', line 29 def post(path, ={}) perform_request(:post, path, ) end |
#tag(device_uid) ⇒ Object
41 42 43 |
# File 'lib/five_mobile_push/client.rb', line 41 def tag(device_uid) FiveMobilePush::Tag.new(self, device_uid) end |