Class: Pushkin::Client
- Inherits:
-
Object
- Object
- Pushkin::Client
- Includes:
- HTTParty
- Defined in:
- lib/pushkin/client.rb
Instance Method Summary collapse
-
#initialize(api_url, api_token) ⇒ Client
constructor
A new instance of Client.
- #push(data) ⇒ Object
Constructor Details
#initialize(api_url, api_token) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pushkin/client.rb', line 6 def initialize(api_url, api_token) @options = { headers: { "Authorization" => "Bearer #{api_token}", "Accept-Language" => "en", "Accept" => "application/json", "Content-Type" => "application/json", "User-Agent" => "Pushkin v#{Pushkin::VERSION}", "Client-Language" => "ruby", "Client-Language-Version" => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})", "Client-Platform" => RUBY_PLATFORM, "Client-Engine" => defined?(RUBY_ENGINE) ? RUBY_ENGINE : "", "Client-Hostname" => Socket.gethostname, "Client-Pid" => Process.pid.to_s, "Client-Thread" => Thread.current.object_id.to_s } } @api_url = api_url end |
Instance Method Details
#push(data) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/pushkin/client.rb', line 26 def push(data) body = prepare_data(data) @options = @options.merge(body: body) self.class.post("#{@api_url}/api/events/", @options) end |