twilio / twilio-ruby

A Ruby gem for communicating with the Twilio API and generating TwiML
MIT License
1.35k stars 462 forks source link

twilio-ruby 6.0.0 Create a US A2P Campaign is not working #658

Closed artempopkov closed 1 year ago

artempopkov commented 1 year ago

Issue Summary

Create a US A2P Campaign is not working

Steps to Reproduce

require 'rubygems'
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

us_app_to_person = @client.messaging
  .v1
  .services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .us_app_to_person
  .create(
     message_flow: 'End users opt-in by visiting www.example.com and adding their phone number. They then check a box agreeing to receive text messages from Example Brand. Additionally, end users can also opt-in by texting START to (111) 222-3333 to opt in. Term and Conditions at www.example.com/tc. Privacy Policy at www.example.com/privacy',
     message_samples: ['EXPRESS: Denim Days Event is ON. Reply STOP to unsubscribe.', 'LAST CHANCE: Book your next flight for just 1 (ONE) EUR'],
     brand_registration_sid: 'BNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
     description: 'description',
     us_app_to_person_usecase: 'us_app_to_person_usecase',
     has_embedded_links: true,
     has_embedded_phone: true
   )

puts us_app_to_person.sid

Exception/Log

ArgumentError: unknown keyword: :service_sid

Problem code

# lib/twilio-ruby/rest/messaging/v1/service.rb:352
 def us_app_to_person(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return UsAppToPersonContext.new(@version, @solution[:sid],sid )
    end

    unless @us_app_to_person
    # Problem => UsAppToPersonList does not accept service_sid
        @us_app_to_person = UsAppToPersonList.new(
            @version, service_sid: @solution[:sid], messaging_service_sid: @solution[:sid],  ) 
    end

    @us_app_to_person
end

# lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb:21
class UsAppToPersonList < ListResource
  def initialize(version, messaging_service_sid: nil)
      super(version)
      # Path Solution
      @solution = { messaging_service_sid: messaging_service_sid }
      @uri = "/Services/#{@solution[:messaging_service_sid]}/Compliance/Usa2p"
  end
end

Technical details:

AsabuHere commented 1 year ago

Hi @artempopkov, Thanks for the heads up!

This issue has been added to our internal backlog and is being worked on(https://github.com/twilio/twilio-ruby/issues/657)

AsabuHere commented 1 year ago

Update: We've identified the issue and are fixing it. Meanwhile, please use v5.77.0

shrutiburman commented 1 year ago

Hi, we've released a new ruby version v6.0.1 with the fix. Please upgrade and let us know if you need further help. Thanks.

Closing this issue, please feel free to open another one if this persists.