Class: LineNotifyClient::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/line_notify_client/http_client.rb

Overview

## LineNotify::Client A class for LINE Notify API client.

Constant Summary collapse

HOST =
'notify-api.line.me'
ACCEPT =
'application/json'
USER_AGENT =
'LineNotify Ruby'
HEADERS =
{ 'Accept' => ACCEPT, 'User-Agent' => USER_AGENT }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ HttpClient

Returns a new instance of HttpClient.



13
14
15
# File 'lib/line_notify_client/http_client.rb', line 13

def initialize(access_token)
  @access_token = access_token
end

Instance Method Details

#notify(message, options = {}) ⇒ Object

### LineNotify::Client#notify Sends notifications to users or groups that are related to an access token.

POST notify-api.line.me/api/notify



21
22
23
24
# File 'lib/line_notify_client/http_client.rb', line 21

def notify(message, options = {})
  params = { message: message }.merge(options)
  post('/api/notify', params, options)
end

#revokeObject

### LineNotify::Client#revoke Disable an access token.

POST notify-api.line.me/api/revoke



38
39
40
# File 'lib/line_notify_client/http_client.rb', line 38

def revoke
  post('/api/revoke')
end

#statusObject

### LineNotify::Client#status Check the validity of an access token.

GET notify-api.line.me/api/status



30
31
32
# File 'lib/line_notify_client/http_client.rb', line 30

def status
  get('/api/status')
end