urbanairship / ruby-library

A Ruby wrapper for the Urban Airship API.
Other
200 stars 117 forks source link

Push email with a template #135

Open paulsUsername opened 2 months ago

paulsUsername commented 2 months ago

I am not seeing anywhere to send a push targeting an email template. From the docs I can see it should be something like this:

"message": {
        "template": {
         "template_id": "b740afd6-36my-email-template",
         "fields": {
            "title": "Test Title",
            "description": "This a description",
            "map": "xxx",
            "recording": "xxx",
            "distance": "xxx",
            "elevation": "xxx",
            "elapsed_time": "xxx",
         }
      }
    }

In email payload I just see this:

```
 def email(bypass_opt_in_level: nil, html_body: nil, message_type: required('message_type'),
            plaintext_body: required('plaintext_body'), reply_to: required('reply_to'),
            sender_address: required('sender_address'), sender_name: required('sender_name'),
            subject: required('subject'))
    fail ArgumentError, 'Message type must not be nil' if message_type.nil?
    fail ArgumentError, 'Plaintext Body must not be nil' if plaintext_body.nil?
    fail ArgumentError, 'Reply To must not be nil' if reply_to.nil?
    fail ArgumentError, 'Sender address must not be nil' if sender_address.nil?
    fail ArgumentError, 'Sender name must not be nil' if sender_name.nil?
    fail ArgumentError, 'Subject must not be nil' if subject.nil?
    compact_helper({
        bypass_opt_in_level: bypass_opt_in_level,
        html_body: html_body,
        message_type: message_type,
        plaintext_body: plaintext_body,
        reply_to: reply_to,
        sender_address: sender_address,
        sender_name: sender_name,
        subject: subject
      })
  end
Jahdeh commented 2 months ago

There are some areas of email that aren't currently supported by the Ruby library, and it's possible we haven't gotten to this yet.

We do have an email notification class which does allow you to add a template ID, though its usage as far as the docs are concerned are mainly for create and send. I personally haven't tested it for anything else, but we do have plans to upgrade multiple areas of the Ruby library which likely includes email. When we get to that point we'll make sure this use case is supported.

Thanks for reporting this!