Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to specify sub-account #30

Open
victusfate opened this issue Nov 14, 2024 · 0 comments
Open

how to specify sub-account #30

victusfate opened this issue Nov 14, 2024 · 0 comments

Comments

@victusfate
Copy link

After reviewing the api docs https://support.messagemedia.com/hc/en-us/articles/4413635760527-Messaging-API I noticed we can specify an account in headers. I didn't see an option to specify an account with the MessageMediaMessagesClient controller.

Do you recommend monkey patching it in?
something like this

require 'message_media_messages'

class CustomMessagesController < MessageMediaMessages::MessagesController
  def send_messages(body, account_id: nil)
    request = MessageMediaMessages::APIHelper.json_serialize(body)
    headers = {
      'Content-Type' => 'application/json'
    }
    headers['Account'] = account_id if account_id

    response = @http_client.post(
      @base_uri + '/v1/messages',
      headers: headers,
      body: request
    )

    validate_response(response)
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant