Logo Lanfrica

Sylvance/africas-talking-services

Domain:

digital infrastructure

Record type:

software
Creator:
Syl
Host:
Gem that helps one to easily create micro-services based on Africa's talking API. # Africas::Talking::Services Gem that helps one to easily create micro-services based on Africa's talking API. Put your Ruby code in the file `lib/africas/talking/services`. To experiment with that code, run `bin/console` for an interactive prompt. ## Installation Install the gem and add to the application's Gemfile by executing: $ bundle add africas-talking-services If bundler is not being used to manage dependencies, install the gem by executing: $ gem install africas-talking-services ## Usage Create your Africa's Talking Service with; ### Voice Service Usage Initialize the voice service first; ```ruby service = Africas::Talking::Services::Client.new(app_name: app_name, app_key: app_key) voice = service.voice ``` #### -> making a voice call ```ruby voice_call_entity = Africas::Talking::Services::VoiceCallEntity.new(from: from, to: to, client_request_id: client_request_id) response = voice.call(entity: voice_call_entity) response.success? # => true ``` #### -> handle a voice callback Within the callback url endpoint do the following; - i) Create a callback object from the callback response ```ruby # create a callback response entity to easily handle the data callback_entity = Africas::Talking::Services::CallbackEntity.new(callback_response: callback_response) # attributes -> is_active, session_id, direction, caller_number, destination_number, get_digits_response, # recording_url, duration_in_seconds, currency_code, amount # you can now use callback_entity to make business domain decisions then proceed below to return a response ``` - ii) Return a response based on the voice methods ```ruby # you can inform the user of something [cloud.google.com] voice_say_entity = Africas::Talking::Services::VoiceSayEntity.new(text: 'Something', voice: 'en-GB-Standard-F', play_beep: true) response = voice.say(entity: voice_say_entity) # or # you can play a pre-recorded audio from a url voice_play_entity = Africas …

Licenses