Class: Semaphore::Sms::Client
- Inherits:
-
Object
- Object
- Semaphore::Sms::Client
- Extended by:
- Forwardable
- Defined in:
- lib/semaphore/sms/client.rb
Defined Under Namespace
Classes: Response
Instance Method Summary collapse
- #account ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #messages(id: nil, page: nil, limit: nil, start_date: nil, end_date: nil, network: nil, status: nil) ⇒ Object
- #priority(message, recipients, sendername = nil) ⇒ Object
- #send(message, recipients, sendername = nil) ⇒ Object
- #sender_names(page: nil, limit: nil) ⇒ Object
- #transactions(page: nil, limit: nil) ⇒ Object
- #users(page: nil, limit: nil) ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
15 16 17 18 |
# File 'lib/semaphore/sms/client.rb', line 15 def initialize(config) raise ConfigurationError, 'Config must have api key credentials' unless config.respond_to? :api_key @config = config end |
Instance Method Details
#account ⇒ Object
58 59 60 |
# File 'lib/semaphore/sms/client.rb', line 58 def account api_get("account") end |
#messages(id: nil, page: nil, limit: nil, start_date: nil, end_date: nil, network: nil, status: nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/semaphore/sms/client.rb', line 46 def (id: nil, page: nil, limit: nil, start_date: nil, end_date: nil, network: nil, status: nil) = { page: page, limit: limit, startDate: start_date, endDate: end_date, network: network, status: status }.compact api_get("messages#{id.nil? ? "" : "/#{id}"}", ) end |
#priority(message, recipients, sendername = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/semaphore/sms/client.rb', line 33 def priority(, recipients, sendername = nil) recipients = clean_and_validate(recipients) raise PhoneNumberError, 'Please verify the phonenumber' unless recipients = { message: , sendername: sendername || sender_name, number: recipients.kind_of?(Array) ? recipients.join(",") : recipients }.compact api_post("priority", ) end |
#send(message, recipients, sendername = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/semaphore/sms/client.rb', line 20 def send(, recipients, sendername = nil) recipients = clean_and_validate(recipients) raise PhoneNumberError, 'Please verify the phonenumber' unless recipients = { message: , sendername: sendername || sender_name, number: recipients }.compact api_post("messages", ) end |
#sender_names(page: nil, limit: nil) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/semaphore/sms/client.rb', line 70 def sender_names(page: nil, limit: nil) = { page: page, limit: limit }.compact api_get("account/sendernames", ) end |
#transactions(page: nil, limit: nil) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/semaphore/sms/client.rb', line 62 def transactions(page: nil, limit: nil) = { page: page, limit: limit }.compact api_get("account/transactions", ) end |
#users(page: nil, limit: nil) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/semaphore/sms/client.rb', line 78 def users(page: nil, limit: nil) = { page: page, limit: limit }.compact api_get("account/users", ) end |