diff --git a/lib/telnyx.rb b/lib/telnyx.rb index 3b72b76..087dcf2 100644 --- a/lib/telnyx.rb +++ b/lib/telnyx.rb @@ -87,6 +87,8 @@ require "telnyx/message" require "telnyx/message_number_pool" require "telnyx/messaging_phone_number" +require "telnyx/messaging_hosted_number_order" +require "telnyx/messaging_hosted_number" require "telnyx/messaging_profile" require "telnyx/messaging_tollfree_verification" require "telnyx/messaging_url_domain" diff --git a/lib/telnyx/brand.rb b/lib/telnyx/brand.rb index 5a0f6e7..7e85b3e 100644 --- a/lib/telnyx/brand.rb +++ b/lib/telnyx/brand.rb @@ -16,5 +16,16 @@ def self.resource_url(inner_id = nil) end OBJECT_NAME = "brand".freeze + + def external_vetting(params = {}, opts = {}) + resp, opts = request(:post, "#{resource_url}/externalVetting", params, opts) + Util.convert_to_telnyx_object(resp.data, opts) + end + + def self.retrieve(id, opts = {}) + instance = new(id, opts) + instance.refresh + instance + end end end diff --git a/lib/telnyx/campaign.rb b/lib/telnyx/campaign.rb index e9e4744..f7c9ae9 100644 --- a/lib/telnyx/campaign.rb +++ b/lib/telnyx/campaign.rb @@ -15,6 +15,11 @@ class Campaign < APIResource operations: [:create], instance_methods: { create: action } end + def self.create(params = {}, opts = {}) + resp, opts = request(:post, "/10dlc/campaignBuilder", params, opts) + Util.convert_to_telnyx_object(resp.data, opts) + end + def accept_sharing(params = {}, opts = {}) resp, opts = request(:post, "/10dlc/campaign/acceptSharing/#{campaignId.gsub(/\s+/, '+')}", params, opts) Util.convert_to_telnyx_object(resp.data, opts) @@ -30,6 +35,11 @@ def osr_attributes(params = {}, opts = {}) Util.convert_to_telnyx_object(resp.data, opts) end + def self.retrieve(id, opts = {}) + resp, opts = request(:get, resource_url(id), {}, opts) + Util.convert_to_telnyx_object(resp.data, opts) + end + def self.resource_url(inner_id = nil) path_prefix = "/10dlc" object_path = "campaign" diff --git a/lib/telnyx/messaging_hosted_number.rb b/lib/telnyx/messaging_hosted_number.rb new file mode 100644 index 0000000..98d1dc0 --- /dev/null +++ b/lib/telnyx/messaging_hosted_number.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Telnyx + class MessagingHostedNumber < APIResource + include Telnyx::APIOperations::Delete + + def self.resource_url(inner_id = nil) + path_prefix = "/v2" + object_path = "messaging_hosted_numbers" + + inner_id.nil? ? "#{path_prefix}/#{object_path}" : "#{path_prefix}/#{object_path}/#{CGI.escape(inner_id)}" + end + + OBJECT_NAME = "messaging_hosted_number".freeze + end +end diff --git a/lib/telnyx/messaging_hosted_number_order.rb b/lib/telnyx/messaging_hosted_number_order.rb index 05927df..56827bd 100644 --- a/lib/telnyx/messaging_hosted_number_order.rb +++ b/lib/telnyx/messaging_hosted_number_order.rb @@ -17,5 +17,10 @@ class MessagingHostedNumberOrder < APIResource end OBJECT_NAME = "messaging_hosted_number_order".freeze + + def upload_file(params = {}, opts = {}) + resp, opts = request(:post, "#{resource_url}/actions/file_upload", params, opts) + Util.convert_to_telnyx_object(resp.data, opts) + end end end diff --git a/lib/telnyx/sim_card.rb b/lib/telnyx/sim_card.rb index fbc3b72..f71b94b 100644 --- a/lib/telnyx/sim_card.rb +++ b/lib/telnyx/sim_card.rb @@ -46,7 +46,11 @@ def self.network_preferences(params = {}, opts = {}) Util.convert_to_telnyx_object(resp.data, opts) end - # depreciated api + def self.retrieve(id, params = {}, opts = {}) + resp, opts = request(:get, "/v2/sim_cards/#{id}", params, opts) + Util.convert_to_telnyx_object(resp.data, opts) + end + def activate warn "[DEPRECATION] SimCard#activate is deprecated, use enable instead." enable diff --git a/lib/telnyx/texml_application.rb b/lib/telnyx/texml_application.rb index bd7fe68..94fd7fd 100644 --- a/lib/telnyx/texml_application.rb +++ b/lib/telnyx/texml_application.rb @@ -3,6 +3,10 @@ module Telnyx class TexmlApplication < APIResource extend Telnyx::APIOperations::List + extend Telnyx::APIOperations::Create + include Telnyx::APIOperations::Delete + include Telnyx::APIOperations::Save + extend APIOperations::NestedResource OBJECT_NAME = "texml_application".freeze end diff --git a/test/telnyx/brand_test.rb b/test/telnyx/brand_test.rb new file mode 100644 index 0000000..02bb0b7 --- /dev/null +++ b/test/telnyx/brand_test.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +module Telnyx + class BrandTest < Test::Unit::TestCase + should "be retrievable" do + brand = Telnyx::Brand.retrieve("123") + assert_requested :get, "#{Telnyx.api_base}/v2/10dlc/brand/123" + assert brand.is_a?(Telnyx::Brand) + end + + should "be creatable" do + brand = Telnyx::Brand.create( + name: "Test Brand", + ein: "12-3456789" + ) + assert_requested :post, "#{Telnyx.api_base}/v2/10dlc/brand" + assert brand.is_a?(Telnyx::Brand) + end + + should "be saveable" do + brand = Telnyx::Brand.retrieve("123") + brand.name = "New Brand Name" + brand.save + assert_requested :post, "#{Telnyx.api_base}/v2/10dlc/brand/123" + end + + should "be deletable" do + brand = Telnyx::Brand.retrieve("123") + brand = brand.delete + assert_requested :delete, "#{Telnyx.api_base}/v2/10dlc/brand/123" + assert brand.is_a?(Telnyx::Brand) + end + + should "be listable" do + brands = Telnyx::Brand.list + assert_requested :get, "#{Telnyx.api_base}/v2/10dlc/brand" + assert brands.data.is_a?(Array) + assert brands.data[0].is_a?(Telnyx::Brand) + end + + should "be able to order external vetting" do + brand = Telnyx::Brand.retrieve("123") + vetting = brand.external_vetting( + vetting_provider: "Aegis Mobile", + vetting_score: 85 + ) + assert_requested :post, "#{Telnyx.api_base}/v2/10dlc/brand/123/externalVetting" + assert vetting.is_a?(Telnyx::TelnyxObject) + end + end +end diff --git a/test/telnyx/messaging_hosted_number_order_test.rb b/test/telnyx/messaging_hosted_number_order_test.rb new file mode 100644 index 0000000..dcb9b2e --- /dev/null +++ b/test/telnyx/messaging_hosted_number_order_test.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Telnyx + class MessagingHostedNumberOrderTest < Test::Unit::TestCase + should "be retrievable" do + order = Telnyx::MessagingHostedNumberOrder.retrieve("123") + assert_requested :get, "#{Telnyx.api_base}/v2/messaging_hosted_number_orders/123" + assert order.is_a?(Telnyx::MessagingHostedNumberOrder) + end + + should "be able to upload a file" do + order = Telnyx::MessagingHostedNumberOrder.retrieve("123") + file_upload = order.upload_file( + loa: File.new("path/to/loa.pdf"), + bill: File.new("path/to/bill.pdf") + ) + assert_requested :post, "#{Telnyx.api_base}/v2/messaging_hosted_number_orders/123/actions/file_upload" + assert file_upload.is_a?(Telnyx::TelnyxObject) + end + + should "be creatable" do + order = Telnyx::MessagingHostedNumberOrder.create( + phone_number: "+1234567890", + messaging_profile_id: "456" + ) + assert_requested :post, "#{Telnyx.api_base}/v2/messaging_hosted_number_orders" + assert order.is_a?(Telnyx::MessagingHostedNumberOrder) + end + + should "be saveable" do + order = Telnyx::MessagingHostedNumberOrder.retrieve("123") + order.phone_number = "+0987654321" + order.save + assert_requested :post, "#{Telnyx.api_base}/v2/messaging_hosted_number_orders/123" + end + + should "be listable" do + orders = Telnyx::MessagingHostedNumberOrder.list + assert_requested :get, "#{Telnyx.api_base}/v2/messaging_hosted_number_orders" + assert orders.data.is_a?(Array) + assert orders.data[0].is_a?(Telnyx::MessagingHostedNumberOrder) + end + end +end