Class: CommandTower::Messaging::Execution::Adapters::Expo::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
app/services/command_tower/messaging/execution/adapters/expo/http_client.rb

Overview

Narrow Expo Push HTTP client for Messaging notification push. Never logs tokens, Authorization headers, or raw bodies that may contain tokens.

Instance Method Summary collapse

Constructor Details

#initialize(configuration: nil) ⇒ HttpClient

Returns a new instance of HttpClient.



15
16
17
# File 'app/services/command_tower/messaging/execution/adapters/expo/http_client.rb', line 15

def initialize(configuration: nil)
  @configuration = configuration || Configuration.new
end

Instance Method Details

#get_receipts(ids) ⇒ Object

ids: Array of ticket id strings. Returns { ok:, status_code:, receipts: { id => { status:, message:, error: } } }



30
31
32
33
# File 'app/services/command_tower/messaging/execution/adapters/expo/http_client.rb', line 30

def get_receipts(ids)
  response = post_json("#{api_base_url}/getReceipts", { "ids" => Array(ids) })
  parse_receipts_response(response)
end

#send_messages(messages) ⇒ Object

messages: Array of Expo message hashes (to/title/body/data). Returns { ok:, status_code:, tickets: [...] } where each ticket is { status:, id:, message:, error: } (error is Expo details.error when present).



22
23
24
25
26
# File 'app/services/command_tower/messaging/execution/adapters/expo/http_client.rb', line 22

def send_messages(messages)
  # Expo Push /send accepts a JSON array of messages.
  response = post_json("#{api_base_url}/send", Array(messages))
  parse_send_response(response)
end