Class: Africastalking::Subscription

Inherits:
Connection show all
Defined in:
lib/africastalking/subscription.rb

Class Method Summary collapse

Methods inherited from Connection

headers

Class Method Details

.create(data) ⇒ Object



5
6
7
8
# File 'lib/africastalking/subscription.rb', line 5

def create(data)
  validate_attributes(%w(phone_number short_code keyword), data)
        post("/version1/subscription/create", build_subscription(data))
end

.delete(data) ⇒ Object



10
11
12
13
# File 'lib/africastalking/subscription.rb', line 10

def delete(data)
        validate_attributes(%w(phone_number short_code keyword), data)
        post("/version1/subscription/delete", build_subscription(data))
end

.fetch(data) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/africastalking/subscription.rb', line 15

def fetch(data)
        validate_attributes(%w(short_code keyword), data)

  fetch_url = %{
    /version1/subscription?
    username=#{Africastalking.config.username}&
    shortCode=#{data.fetch(:short_code)}&keyword=#{data.fetch(:keyword)}&
    lastReceivedId=#{data.fetch(:last_received_id, 0)}
  }

        get(fetch_url)
end