Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Programmable Messaging APIs #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ex_twilio/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ defmodule ExTwilio.Config do

def video_url, do: "https://video.twilio.com/v1"

def programmable_messaging_url, do: "https://messaging.twilio.com/v1"

@doc """
A light wrapper around `Application.get_env/2`, providing automatic support for
`{:system, "VAR"}` tuples.
Expand Down
29 changes: 29 additions & 0 deletions lib/ex_twilio/resources/programmable_messaging/alpha_sender.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
defmodule ExTwilio.ProgrammableMessaging.AlphaSender do
@moduledoc """
Represents an AlphaSender resource in the Twilio Programmable Messaging API.

- [Twilio docs](https://www.twilio.com/docs/messaging/services/api/alphasender-resource)
"""
defstruct sid: nil,
account_sid: nil,
service_sid: nil,
date_created: nil,
date_updated: nil,
alpha_sender: nil,
capabilities: nil,
url: nil

use ExTwilio.Resource,
import: [
:stream,
:all,
:find,
:create,
:destroy
]

def parents,
do: [
%ExTwilio.Parent{module: ExTwilio.ProgrammableMessaging.Service, key: :service}
]
end
30 changes: 30 additions & 0 deletions lib/ex_twilio/resources/programmable_messaging/phone_number.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
defmodule ExTwilio.ProgrammableMessaging.PhoneNumber do
@moduledoc """
Represents a PhoneNumber resource in the Twilio Programmable Messaging API.

- [Twilio docs](https://www.twilio.com/docs/messaging/services/api/phonenumber-resource)
"""
defstruct sid: nil,
account_sid: nil,
service_sid: nil,
date_created: nil,
date_updated: nil,
phone_number: nil,
country_code: nil,
capabilities: nil,
url: nil

use ExTwilio.Resource,
import: [
:stream,
:all,
:find,
:create,
:destroy
]

def parents,
do: [
%ExTwilio.Parent{module: ExTwilio.ProgrammableMessaging.Service, key: :service}
]
end
38 changes: 38 additions & 0 deletions lib/ex_twilio/resources/programmable_messaging/service.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
defmodule ExTwilio.ProgrammableMessaging.Service do
@moduledoc """
Represents a Service resource in the Twilio Programmable Messaging API.

- [Twilio docs](https://www.twilio.com/docs/messaging/services/api)
"""
defstruct sid: nil,
account_sid: nil,
friendly_name: nil,
date_created: nil,
date_updated: nil,
inbound_request_url: nil,
inbound_method: nil,
fallback_url: nil,
fallback_method: nil,
status_callback: nil,
sticky_sender: nil,
mms_converter: nil,
smart_encoding: nil,
scan_message_content: nil,
fallback_to_long_code: nil,
area_code_geomatch: nil,
synchronous_validation: nil,
validity_period: nil,
url: nil,
links: nil,
use_inbound_webhook_on_number: nil

use ExTwilio.Resource,
import: [
:stream,
:all,
:find,
:create,
:update,
:destroy
]
end
30 changes: 30 additions & 0 deletions lib/ex_twilio/resources/programmable_messaging/short_code.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
defmodule ExTwilio.ProgrammableMessaging.ShortCode do
@moduledoc """
Represents a ShortCode resource in the Twilio Programmable Messaging API.

- [Twilio docs](https://www.twilio.com/docs/messaging/services/api/shortcode-resource)
"""
defstruct sid: nil,
account_sid: nil,
service_sid: nil,
date_created: nil,
date_updated: nil,
short_code: nil,
country_code: nil,
capabilities: nil,
url: nil

use ExTwilio.Resource,
import: [
:stream,
:all,
:find,
:create,
:destroy
]

def parents,
do: [
%ExTwilio.Parent{module: ExTwilio.ProgrammableMessaging.Service, key: :service}
]
end
4 changes: 4 additions & 0 deletions lib/ex_twilio/url_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ defmodule ExTwilio.UrlGenerator do
url = add_segments(Config.video_url(), module, id, options)
{url, options}

["ExTwilio", "ProgrammableMessaging" | _] ->
url = add_segments(Config.programmable_messaging_url(), module, id, options)
{url, options}

_ ->
# Add Account SID segment if not already present
options = add_account_to_options(module, options)
Expand Down