Module: NotificationService::Sms::Kaleyra::APIConfig
- Included in:
- Service
- Defined in:
- app/services/notification_service/sms/kaleyra/api_config.rb
Instance Method Summary collapse
- #default_params ⇒ Object
- #endpoint ⇒ Object
- #headers ⇒ Object
-
#sort_params(params, sort = 'asc') ⇒ Hash
Sorts the given parameters in ascending or descending order based on the specified sort order (default asc).
Instance Method Details
#default_params ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/services/notification_service/sms/kaleyra/api_config.rb', line 8 def default_params { sender: 'HungryHub', type: 'DEFAULT', unicode: 'AUTO', } end |
#endpoint ⇒ Object
3 4 5 6 |
# File 'app/services/notification_service/sms/kaleyra/api_config.rb', line 3 def endpoint sid = Figaro.env.KALEYRA_IO_SID_KEY! "#{AdminSetting.kaleyra_io_api_host}/#{sid}/messages" end |
#headers ⇒ Object
16 17 18 19 20 21 |
# File 'app/services/notification_service/sms/kaleyra/api_config.rb', line 16 def headers api_key = Figaro.env.KALEYRA_IO_API_KEY! { "api-key": api_key, } end |
#sort_params(params, sort = 'asc') ⇒ Hash
Sorts the given parameters in ascending or descending order based on the specified sort order (default asc).
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/services/notification_service/sms/kaleyra/api_config.rb', line 29 def sort_params(params, sort = 'asc') unless params.is_a?(Hash) raise ArgumentError, "Params must be a hash, got #{params.class} instead." end case sort.downcase when 'asc' params.sort.to_h when 'desc' params.sort.reverse.to_h else raise ArgumentError, "Invalid sort order: #{sort}. Use 'asc' or 'desc'." end end |