Class: Apiwha::Api
- Inherits:
-
Object
- Object
- Apiwha::Api
- Defined in:
- lib/apiwha/api.rb
Constant Summary collapse
- API_URL =
'https://panel.apiwha.com'- DEFAULT_OPTIONS =
{ number: nil, type: nil, markaspulled: "0", getnotpulledonly: "0", limit: 100, orderdesc: "1" }.freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #get_credit ⇒ Object
-
#initialize(api_key) ⇒ Api
constructor
A new instance of Api.
- #pull_messages(params: DEFAULT_OPTIONS) ⇒ Object
- #send_message(text:, number:, custom_data: {}) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Api
Returns a new instance of Api.
19 20 21 |
# File 'lib/apiwha/api.rb', line 19 def initialize(api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
17 18 19 |
# File 'lib/apiwha/api.rb', line 17 def api_key @api_key end |
Instance Method Details
#get_credit ⇒ Object
41 42 43 44 45 |
# File 'lib/apiwha/api.rb', line 41 def get_credit response = RestClient.get("#{API_URL}/get_credit.php?apikey=#{@api_key}") response(response: response) end |
#pull_messages(params: DEFAULT_OPTIONS) ⇒ Object
23 24 25 26 |
# File 'lib/apiwha/api.rb', line 23 def (params: DEFAULT_OPTIONS) response = RestClient.get("#{API_URL}/get_messages.php?apikey=#{@api_key}", { params: params }) response(response: response) end |
#send_message(text:, number:, custom_data: {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/apiwha/api.rb', line 28 def (text: , number: , custom_data: {}) payload = { text: text, number: number, apikey: @api_key, custom_data: custom_data.to_json } response = RestClient.post "#{API_URL}/send_message.php?", payload response(response: response) end |