Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardd committed Mar 20, 2024
1 parent 4eb6d05 commit a5020db
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
6 changes: 4 additions & 2 deletions lib/ex_aws/chime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defmodule ExAws.Chime do
def get_request(action, params, service), do: rest_request(action, params, :get, service)
def post_request(action, params, service), do: rest_request(action, params, :post, service)

@spec rest_request(String.t(), map(), atom(), atom()) :: RestQuery.t()
defp rest_request(action, params \\ %{}, method, service) do
%RestQuery{
http_method: method,
Expand All @@ -24,7 +25,8 @@ defmodule ExAws.Chime do
}
end

def json_request(path, params \\ %{}, data, method \\ :post, service) do
@spec json_request(String.t(), map(), map(), atom(), atom()) :: JSON.t()
def json_request(path, params, data, method, service) do
%JSON{
http_method: method,
params: params,
Expand All @@ -44,7 +46,7 @@ defmodule ExAws.Chime do

def normalise_data(struct) when is_map(struct) do
struct
|> Map.drop([:__struct__])
|> Map.delete(:__struct__)
|> Enum.reduce(%{}, fn
{_k, nil}, acc -> acc
{k, v}, acc when is_atom(k) -> Map.put(acc, Macro.camelize(to_string(k)), normalise_data(v))
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_aws/chime/identity.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule ExAws.Chime.Identity do
alias ExAws.Operation.JSON
alias ExAws.Operation.RestQuery

@service "chime-sdk-identity"
@service :"chime-sdk-identity"

@spec list_tags_for_resource(String.t()) :: RestQuery.t()
def list_tags_for_resource(resource_arn) do
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_aws/chime/media_pipelines.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ defmodule ExAws.Chime.MediaPipelines do
### HELPERS

defp json_request(path, data, method \\ :post),
do: Chime.json_request(path, data, method, @service)
do: Chime.json_request(path, %{}, data, method, @service)
end
6 changes: 4 additions & 2 deletions lib/ex_aws/chime/meetings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ defmodule ExAws.Chime.Meetings do
def create_attendee(meeting_id, create_attendee) do
json_request(
"/meetings/#{meeting_id}/attendees",
%{},
create_attendee
)
end
Expand All @@ -52,6 +53,7 @@ defmodule ExAws.Chime.Meetings do
) do
json_request(
"/meetings",
%{},
%{
"ClientRequestToken" => UUID.uuid4(),
"ExternalMeetingId" => external_meeting_id,
Expand Down Expand Up @@ -176,8 +178,8 @@ defmodule ExAws.Chime.Meetings do
end

### HELPERS
defp json_request(path, data, method \\ :post),
do: Chime.json_request(path, data, method, @service)
defp json_request(path, params, data),
do: Chime.json_request(path, params, data, :post, @service)

defp delete_request(path), do: Chime.delete_request(path, @service)

Expand Down
4 changes: 4 additions & 0 deletions lib/ex_aws/chime/utils.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
defmodule ExAws.Chime.Utils do
@moduledoc """
Common helper functions for Chime services
"""

@type max_results :: pos_integer() | nil
@type paging_token :: String.t() | nil

Expand Down
17 changes: 13 additions & 4 deletions lib/ex_aws/chime/voice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ defmodule ExAws.Chime.Voice do
"""

alias ExAws.Chime
alias ExAws.Chime.Tag
alias ExAws.Chime.Utils
alias ExAws.Chime.Voice.BusinessCallingSettings
alias ExAws.Chime.Voice.Credentials
alias ExAws.Chime.Voice.EmergencyCallingConfiguration
Expand All @@ -16,8 +18,6 @@ defmodule ExAws.Chime.Voice do
alias ExAws.Chime.Voice.UpdatePhoneNumberRequestItem
alias ExAws.Chime.Voice.VoiceConnectorItem
alias ExAws.Chime.Voice.VoiceConnectorSettings
alias ExAws.Chime.Tag
alias ExAws.Chime.Utils
alias ExAws.Operation.JSON
alias ExAws.Operation.RestQuery

Expand Down Expand Up @@ -363,6 +363,7 @@ defmodule ExAws.Chime.Voice do
) do
json_request(
"/voice-connectors/#{voice_connector_id}/emergency-calling-configuration",
%{},
%{
"EmergencyCallingConfiguration" => emergency_calling_configuration
},
Expand All @@ -375,6 +376,7 @@ defmodule ExAws.Chime.Voice do
def put_voice_connector_logging_configuration(voice_connector_id, logging_configuration) do
json_request(
"/voice-connectors/#{voice_connector_id}/logging-configuration",
%{},
%{
"LoggingConfiguration" => logging_configuration
},
Expand All @@ -386,6 +388,7 @@ defmodule ExAws.Chime.Voice do
def put_voice_connector_origination(voice_connector_id, origination) do
json_request(
"/voice-connectors/#{voice_connector_id}/origination",
%{},
%{
"Origination" => origination
},
Expand All @@ -405,6 +408,7 @@ defmodule ExAws.Chime.Voice do
) do
json_request(
"/voice-connectors/#{voice_connector_id}/programmable-numbers/proxy",
%{},
%{
"DefaultSessionExpiryMinutes" => default_session_expiry_minutes,
"Disabled" => disabled,
Expand All @@ -420,6 +424,7 @@ defmodule ExAws.Chime.Voice do
def put_voice_connector_streaming_configuration(voice_connector_id, streaming_configuration) do
json_request(
"/voice-connectors/#{voice_connector_id}/streaming-configuration",
%{},
%{
"StreamingConfiguration" => streaming_configuration
},
Expand All @@ -431,6 +436,7 @@ defmodule ExAws.Chime.Voice do
def put_voice_connector_termination(voice_connector_id, termination) do
json_request(
"/voice-connectors/#{voice_connector_id}/termination",
%{},
%{
"Termination" => termination
},
Expand Down Expand Up @@ -501,6 +507,7 @@ defmodule ExAws.Chime.Voice do
def update_global_settings(business_calling, voice_connector) do
json_request(
"/settings",
%{},
%{
"BusinessCalling" => business_calling,
"VoiceConnector" => voice_connector
Expand All @@ -524,6 +531,7 @@ defmodule ExAws.Chime.Voice do
def update_phone_number_settings(calling_name) do
json_request(
"/settings/phone-number",
%{},
%{
"CallingName" => calling_name
},
Expand Down Expand Up @@ -558,6 +566,7 @@ defmodule ExAws.Chime.Voice do
def update_voice_connector_group(voice_connector_group_id, name, voice_connector_items) do
json_request(
"/voice-connectors/#{voice_connector_group_id}",
%{},
%{
"Name" => name,
"VoiceConnectorItems" => voice_connector_items
Expand All @@ -568,8 +577,8 @@ defmodule ExAws.Chime.Voice do

### HELPERS

defp json_request(path, data, method \\ :post),
do: Chime.json_request(path, data, method, @service)
defp json_request(path, params \\ %{}, data, method \\ :post),
do: Chime.json_request(path, params, data, method, @service)

defp delete_request(action), do: Chime.delete_request(action, @service)
defp get_request(action, params \\ %{}), do: Chime.get_request(action, params, @service)
Expand Down

0 comments on commit a5020db

Please sign in to comment.