Skip to content

Commit

Permalink
feat(api-client): add upload for lansen keys
Browse files Browse the repository at this point in the history
- introduce functionality for uploading lansen key files
- add API client method to support lansen keys upload
- extend api client behavior with new callback for lansen keys
- update api client mock with corresponding mock method

This feature supports new encryption key management capabilities.
  • Loading branch information
aamikkelsenWH committed Oct 24, 2024
1 parent d9ffa7f commit 3402e34
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/wise_homex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ defmodule WiseHomex do
"""
def upload_bmeters_keys(config, opts), do: api_client().upload_bmeters_keys(config, opts)

# Lansen Keys

@doc """
Upload a lansen key file
"""
def upload_lansen_keys(config, opts), do: api_client().upload_lansen_keys(config, opts)

# Calculate missing readings
def calculate_missing_readings(config, statement_id),
do: api_client().calculate_missing_readings(config, statement_id)
Expand Down
3 changes: 3 additions & 0 deletions lib/wise_homex/api_client_behaviour.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ defmodule WiseHomex.ApiClientBehaviour do
# Bmeters Keys
@callback upload_bmeters_keys(Config.t(), list) :: response

# Lansen Keys
@callback upload_lansen_keys(Config.t(), list) :: response

# Broken Account Payment
@callback delete_broken_account_payment(Config.t(), id) :: response
@callback get_broken_account_payment(Config.t(), id, query) :: response
Expand Down
16 changes: 16 additions & 0 deletions lib/wise_homex/api_client_impl/api_client_impl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ defmodule WiseHomex.ApiClientImpl do
Request.post(config, "/bmeters/keys", payload)
end

# Lansen Keys
def upload_lansen_keys(config, file_base64: file_base64) do
payload =
%{
data: %{
type: "encryption-keys",
attributes: %{
file_base64: file_base64
}
}
}
|> normalize_payload

Request.post(config, "/lansen/keys", payload)
end

# Calculate missing readings
def calculate_missing_readings(config, statement_id) do
payload =
Expand Down
5 changes: 5 additions & 0 deletions lib/wise_homex/test/api_client_mock/api_client_mock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ defmodule WiseHomex.Test.ApiClientMock do
call_and_get_mock_value(:upload_bmeters_keys, %{opts: opts})
end

# Lansen Keys
def upload_lansen_keys(_config, opts) do
call_and_get_mock_value(:upload_lansen_keys, %{opts: opts})
end

# Calculate missing readings
def calculate_missing_readings(_config, statement_id) do
call_and_get_mock_value(:calculate_missing_readings, %{statement_id: statement_id})
Expand Down

0 comments on commit 3402e34

Please sign in to comment.