Module: EventMachine::Smsified::SubscriptionsModule

Included in:
OneAPI, Subscriptions
Defined in:
lib/em-smsified/subscriptions.rb

Instance Method Summary collapse

Instance Method Details

#create_inbound_subscription(destination_address, options, &blk) ⇒ Object

Creates an inbound subscription

Examples:

subscriptions.create_inbound_subscription('tel:+14155551212', :notify_url => 'http://foobar.com')

Parameters:

  • destination_address (required, String)

    to subscribe to

  • params (required, Hash)

    to send an sms

  • notify_url (required, String)

    to send callbacks to

Returns:

  • (Object)

    A Response Object with http and data instance methods

  • (Object)

    A Response Object with http and data instance methods



17
18
19
20
21
22
23
24
25
# File 'lib/em-smsified/subscriptions.rb', line 17

def create_inbound_subscription(destination_address, options, &blk)
  query = options.merge({ :destination_address => destination_address })
  
  post("/smsmessaging/inbound/subscriptions", 
       camelcase_keys(query),
       SMSIFIED_HTTP_HEADERS, &blk
       )

end

#create_outbound_subscription(sender_address, options, &blk) ⇒ Object

Creates an outbound subscription

Examples:

subscriptions.create_outbound_subscription('tel:+14155551212', :notify_url => 'http://foobar.com')    

Parameters:

  • sender_address (required, String)

    to subscribe to

  • params (Hash)

    a customizable set of options

Returns:

  • (Object)

    A Response Object with http and data instance methods



37
38
39
40
41
42
# File 'lib/em-smsified/subscriptions.rb', line 37

def create_outbound_subscription(sender_address, options, &blk)
  post("/smsmessaging/outbound/#{sender_address}/subscriptions", 
       build_query_string(options),
       SMSIFIED_HTTP_HEADERS, &blk
       )
end

#delete_inbound_subscription(subscription_id, &blk) ⇒ Object

Deletes an inbound subscription

Examples:

subscriptions.delete_inbound_subscription('89edd71c1c7f3d349f9a3a4d5d2d410c')

Parameters:

  • subscription_id (required, String)

    to delete

Returns:

  • (Object)

    A Response Object with http and data instance methods



51
52
53
# File 'lib/em-smsified/subscriptions.rb', line 51

def delete_inbound_subscription(subscription_id, &blk)
  delete("/smsmessaging/inbound/subscriptions/#{subscription_id}", SMSIFIED_HTTP_HEADERS, &blk)
end

#delete_outbound_subscription(subscription_id, &blk) ⇒ Object

Deletes an outbound subscription

Examples:

subscriptions.delete_outbound_subscription('89edd71c1c7f3d349f9a3a4d5d2d410c')

Parameters:

  • subscription_id (required, String)

    to delete

Returns:

  • (Object)

    A Response Object with http and data instance methods



62
63
64
# File 'lib/em-smsified/subscriptions.rb', line 62

def delete_outbound_subscription(subscription_id, &blk)
  delete("/smsmessaging/outbound/subscriptions/#{subscription_id}", SMSIFIED_HTTP_HEADERS, &blk)
end

#inbound_subscriptions(destination_address, &blk) ⇒ Object

Fetches the inbound subscriptions

Examples:

subscriptions.inbound_subscriptions('tel:+14155551212')

Parameters:

  • destination_address (required, String)

    to fetch the subscriptions for

Returns:

  • (Object)

    A Response Object with http and data instance methods



73
74
75
# File 'lib/em-smsified/subscriptions.rb', line 73

def inbound_subscriptions(destination_address, &blk)
  get("/smsmessaging/inbound/subscriptions?destinationAddress=#{destination_address}",  SMSIFIED_HTTP_HEADERS, &blk)
end

#outbound_subscriptions(sender_address, &blk) ⇒ Object

Fetches the outbound subscriptions

Examples:

subscriptions.outbound_subscriptions('tel:+14155551212')

Parameters:

  • sender_address (required, String)

    to fetch the subscriptions for

Returns:

  • (Object)

    A Response Object with http and data instance methods



84
85
86
# File 'lib/em-smsified/subscriptions.rb', line 84

def outbound_subscriptions(sender_address, &blk)
  get("/smsmessaging/outbound/subscriptions?senderAddress=#{sender_address}", SMSIFIED_HTTP_HEADERS, &blk)
end

#update_inbound_subscription(subscription_id, options, &blk) ⇒ Object

Updates an inbound subscription

Examples:

subscriptions.update_inbound_subscription('89edd71c1c7f3d349f9a3a4d5d2d410c', :notify_url => 'foobar')

Parameters:

  • params (required, Hash)

    to update the inbound subscription with

Returns:

  • (Object)

    A Response Object with http and data instance methods



99
100
101
102
103
104
# File 'lib/em-smsified/subscriptions.rb', line 99

def update_inbound_subscription(subscription_id, options, &blk)
  post("/smsmessaging/inbound/subscriptions/#{subscription_id}", 
       build_query_string(options),
       SMSIFIED_HTTP_HEADERS, &blk
       )
end

#update_outbound_subscription(sender_address, options, &blk) ⇒ Object

Updates an outbound subscription

Examples:

subscriptions.update_outbound_subscription('tel:+14155551212', :notify_url => 'foobar')

Parameters:

  • params (required, Hash)

    to update the outbound subscription with

Returns:

  • (Object)

    A Response Object with http and data instance methods



117
118
119
120
121
# File 'lib/em-smsified/subscriptions.rb', line 117

def update_outbound_subscription(sender_address, options, &blk)
  post("/smsmessaging/outbound/#{sender_address}/subscriptions",                                   build_query_string(options), 
       SMSIFIED_HTTP_HEADERS, &blk
       )
end