Module: Whathor
- Defined in:
- lib/whathor.rb,
lib/whathor/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
Class Method Details
.message(to: '', body: '') ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/whathor.rb', line 18 def self.(to: '', body: '') raise ArgumentError.new("number of receiver\'s message is empty") unless !to.empty? raise ArgumentError.new("body of message is empty") unless !body.empty? return false if @token.nil? resp = RestClient.post 'https://api.wha.tools/v0/message', key: @token, to: to, body: body, ack: true # => "{\"result\": \"0123456789-0\", \"success\": true}" JSON.parse(resp, symbolize_names: true)[:success] end |
.subscribe(token) ⇒ Object
6 7 8 9 10 |
# File 'lib/whathor.rb', line 6 def self.subscribe(token) @token = token resp = RestClient.get 'https://api.wha.tools/v0/subscribe', {params: {key: @token}} # => "{\"success\": true}" JSON.parse(resp, symbolize_names: true)[:success] end |
.unsubscribe ⇒ Object
12 13 14 15 16 |
# File 'lib/whathor.rb', line 12 def self.unsubscribe return false if @token.nil? resp = RestClient.get 'https://api.wha.tools/v0/unsubscribe', {params: {key: @token}} # => "{\"success\": true}" JSON.parse(resp, symbolize_names: true)[:success] end |