unione-ruby 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +99 -8
- data/Rakefile +52 -0
- data/config/response_schema/domain.yml +74 -0
- data/config/response_schema/email.yml +23 -0
- data/config/response_schema/event_dump.yml +75 -0
- data/config/response_schema/project.yml +59 -0
- data/config/response_schema/suppression.yml +71 -0
- data/config/response_schema/system.yml +33 -0
- data/config/response_schema/tag.yml +26 -0
- data/config/response_schema/template.yml +134 -0
- data/config/response_schema/unsubscribed.yml +45 -0
- data/config/response_schema/webhook.yml +141 -0
- data/examples/api/custom_api.rb +14 -0
- data/examples/api/domain.rb +14 -7
- data/examples/api/email/attachments.rb +28 -0
- data/examples/api/email/multiple_recipients.rb +24 -0
- data/examples/api/email/send.rb +25 -0
- data/examples/api/email/settings.rb +41 -0
- data/examples/api/email/subscribe.rb +14 -0
- data/examples/api/email/template.rb +26 -0
- data/examples/api/event_dump.rb +44 -0
- data/examples/api/project.rb +35 -11
- data/examples/api/suppression.rb +34 -0
- data/examples/api/system.rb +10 -0
- data/examples/api/tag.rb +15 -0
- data/examples/api/template.rb +40 -22
- data/examples/api/unsubscribed.rb +20 -12
- data/examples/api/webhook.rb +34 -24
- data/examples/helpers.rb +29 -0
- data/examples/send_mail.rb +44 -0
- data/examples/setup.rb +34 -0
- data/lib/unione/client/domain.rb +19 -46
- data/lib/unione/client/email.rb +14 -21
- data/lib/unione/client/event_dump.rb +37 -0
- data/lib/unione/client/project.rb +19 -43
- data/lib/unione/client/suppression.rb +38 -0
- data/lib/unione/client/system.rb +19 -0
- data/lib/unione/client/tag.rb +24 -0
- data/lib/unione/client/template.rb +19 -65
- data/lib/unione/client/unsubscribed.rb +18 -31
- data/lib/unione/client/webhook.rb +19 -38
- data/lib/unione/client.rb +42 -17
- data/lib/unione/connection.rb +24 -16
- data/lib/unione/helpers.rb +22 -0
- data/lib/unione/response/raise_error.rb +4 -5
- data/lib/unione/validation.rb +32 -12
- data/lib/unione/version.rb +1 -1
- data/lib/unione-ruby.rb +0 -3
- data/test/CONFIGFILE.yml +71 -0
- data/unione-ruby.gemspec +2 -2
- metadata +36 -11
- data/examples/1_setup.rb +0 -25
- data/examples/2_mail_sending.rb +0 -23
- data/examples/api/email.rb +0 -36
- data/lib/unione/helpers/mail/mail.rb +0 -37
- data/lib/unione/helpers/template/template.rb +0 -31
- data/lib/unione/helpers/webhook/webhook.rb +0 -17
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            unsubscribe:
         | 
| 2 | 
            +
              type: object
         | 
| 3 | 
            +
              required:
         | 
| 4 | 
            +
                - status
         | 
| 5 | 
            +
                - address
         | 
| 6 | 
            +
                - message
         | 
| 7 | 
            +
              properties:
         | 
| 8 | 
            +
                status:
         | 
| 9 | 
            +
                  type: string
         | 
| 10 | 
            +
                address:
         | 
| 11 | 
            +
                  type: string
         | 
| 12 | 
            +
                message:
         | 
| 13 | 
            +
                  type: string
         | 
| 14 | 
            +
            check_unsubscribed:
         | 
| 15 | 
            +
              type: object
         | 
| 16 | 
            +
              required:
         | 
| 17 | 
            +
                - status
         | 
| 18 | 
            +
                - address
         | 
| 19 | 
            +
                - is_unsubscribed
         | 
| 20 | 
            +
              properties:
         | 
| 21 | 
            +
                status:
         | 
| 22 | 
            +
                  type: string
         | 
| 23 | 
            +
                address:
         | 
| 24 | 
            +
                  type: string
         | 
| 25 | 
            +
                is_unsubscribed:
         | 
| 26 | 
            +
                  type: boolean
         | 
| 27 | 
            +
            list_unsubscribed:
         | 
| 28 | 
            +
              type: object
         | 
| 29 | 
            +
              required:
         | 
| 30 | 
            +
                - status
         | 
| 31 | 
            +
                - unsubscribed
         | 
| 32 | 
            +
              properties:
         | 
| 33 | 
            +
                status:
         | 
| 34 | 
            +
                  type: string
         | 
| 35 | 
            +
                unsubscribed:
         | 
| 36 | 
            +
                  items:
         | 
| 37 | 
            +
                    type: object
         | 
| 38 | 
            +
                  required:
         | 
| 39 | 
            +
                    - address
         | 
| 40 | 
            +
                    - unsubscribed_on
         | 
| 41 | 
            +
                  properties:
         | 
| 42 | 
            +
                    address:
         | 
| 43 | 
            +
                      type: string
         | 
| 44 | 
            +
                    unsubscribed_on:
         | 
| 45 | 
            +
                      type: string
         | 
| @@ -0,0 +1,141 @@ | |
| 1 | 
            +
            set_webhook:
         | 
| 2 | 
            +
              type: object
         | 
| 3 | 
            +
              required:
         | 
| 4 | 
            +
                - status
         | 
| 5 | 
            +
                - object
         | 
| 6 | 
            +
              properties:
         | 
| 7 | 
            +
                status:
         | 
| 8 | 
            +
                  type: string
         | 
| 9 | 
            +
                object:
         | 
| 10 | 
            +
                  type: object
         | 
| 11 | 
            +
                  required:
         | 
| 12 | 
            +
                    - url
         | 
| 13 | 
            +
                    - status
         | 
| 14 | 
            +
                    - events
         | 
| 15 | 
            +
                    - event_format
         | 
| 16 | 
            +
                    - delivery_info
         | 
| 17 | 
            +
                    - single_event
         | 
| 18 | 
            +
                    - max_parallel
         | 
| 19 | 
            +
                  properties:
         | 
| 20 | 
            +
                    id:
         | 
| 21 | 
            +
                      type: integer
         | 
| 22 | 
            +
                    url:
         | 
| 23 | 
            +
                      type: string
         | 
| 24 | 
            +
                    status:
         | 
| 25 | 
            +
                      type: string
         | 
| 26 | 
            +
                    event_format:
         | 
| 27 | 
            +
                      type: string
         | 
| 28 | 
            +
                    delivery_info:
         | 
| 29 | 
            +
                      type: integer
         | 
| 30 | 
            +
                    single_event:
         | 
| 31 | 
            +
                      type: integer
         | 
| 32 | 
            +
                    max_parallel:
         | 
| 33 | 
            +
                      type: integer
         | 
| 34 | 
            +
                    events:
         | 
| 35 | 
            +
                      type: object
         | 
| 36 | 
            +
                      required:
         | 
| 37 | 
            +
                        - email_status
         | 
| 38 | 
            +
                        - spam_block
         | 
| 39 | 
            +
                      properties:
         | 
| 40 | 
            +
                       email_status:
         | 
| 41 | 
            +
                         items:
         | 
| 42 | 
            +
                           type: string
         | 
| 43 | 
            +
                       spam_block:
         | 
| 44 | 
            +
                         items:
         | 
| 45 | 
            +
                           type: string
         | 
| 46 | 
            +
            get_webhook:
         | 
| 47 | 
            +
              type: object
         | 
| 48 | 
            +
              required:
         | 
| 49 | 
            +
                - status
         | 
| 50 | 
            +
                - object
         | 
| 51 | 
            +
              properties:
         | 
| 52 | 
            +
                status:
         | 
| 53 | 
            +
                  type: string
         | 
| 54 | 
            +
                object:
         | 
| 55 | 
            +
                  type: object
         | 
| 56 | 
            +
                  required:
         | 
| 57 | 
            +
                    - url
         | 
| 58 | 
            +
                    - status
         | 
| 59 | 
            +
                    - events
         | 
| 60 | 
            +
                    - event_format
         | 
| 61 | 
            +
                    - max_parallel
         | 
| 62 | 
            +
                  properties:
         | 
| 63 | 
            +
                    id:
         | 
| 64 | 
            +
                      type: integer
         | 
| 65 | 
            +
                    url:
         | 
| 66 | 
            +
                      type: string
         | 
| 67 | 
            +
                    status:
         | 
| 68 | 
            +
                      type: string
         | 
| 69 | 
            +
                    event_format:
         | 
| 70 | 
            +
                      type: string
         | 
| 71 | 
            +
                    max_parallel:
         | 
| 72 | 
            +
                      type: integer
         | 
| 73 | 
            +
                    events:
         | 
| 74 | 
            +
                      type: object
         | 
| 75 | 
            +
                      required:
         | 
| 76 | 
            +
                        - email_status
         | 
| 77 | 
            +
                        - spam_block
         | 
| 78 | 
            +
                      properties:
         | 
| 79 | 
            +
                       email_status:
         | 
| 80 | 
            +
                         items:
         | 
| 81 | 
            +
                           type: string
         | 
| 82 | 
            +
                       spam_block:
         | 
| 83 | 
            +
                         items:
         | 
| 84 | 
            +
                           type: string
         | 
| 85 | 
            +
            list_webhooks:
         | 
| 86 | 
            +
              type: object
         | 
| 87 | 
            +
              required:
         | 
| 88 | 
            +
                - status
         | 
| 89 | 
            +
                - objects
         | 
| 90 | 
            +
              properties:
         | 
| 91 | 
            +
                status:
         | 
| 92 | 
            +
                  type: string
         | 
| 93 | 
            +
                objects:
         | 
| 94 | 
            +
                  items:
         | 
| 95 | 
            +
                    type: object
         | 
| 96 | 
            +
                    required:
         | 
| 97 | 
            +
                      - id
         | 
| 98 | 
            +
                      - url
         | 
| 99 | 
            +
                      - status
         | 
| 100 | 
            +
                      - updated_at
         | 
| 101 | 
            +
                      - events
         | 
| 102 | 
            +
                      - event_format
         | 
| 103 | 
            +
                      - delivery_info
         | 
| 104 | 
            +
                      - single_event
         | 
| 105 | 
            +
                      - max_parallel
         | 
| 106 | 
            +
                    properties:
         | 
| 107 | 
            +
                       id:
         | 
| 108 | 
            +
                         type: integer
         | 
| 109 | 
            +
                       url:
         | 
| 110 | 
            +
                         type: string
         | 
| 111 | 
            +
                       status:
         | 
| 112 | 
            +
                         type: string
         | 
| 113 | 
            +
                       event_format:
         | 
| 114 | 
            +
                         type: string
         | 
| 115 | 
            +
                       delivery_info:
         | 
| 116 | 
            +
                         type: integer
         | 
| 117 | 
            +
                       single_event:
         | 
| 118 | 
            +
                         type: integer
         | 
| 119 | 
            +
                       max_parallel:
         | 
| 120 | 
            +
                         type: integer
         | 
| 121 | 
            +
                       updated_at:
         | 
| 122 | 
            +
                         type: string
         | 
| 123 | 
            +
                       events:
         | 
| 124 | 
            +
                         type: object
         | 
| 125 | 
            +
                         required:
         | 
| 126 | 
            +
                           - email_status
         | 
| 127 | 
            +
                           - spam_block
         | 
| 128 | 
            +
                         properties:
         | 
| 129 | 
            +
                           spam_block:
         | 
| 130 | 
            +
                             items:
         | 
| 131 | 
            +
                               type: string
         | 
| 132 | 
            +
                           email_status:
         | 
| 133 | 
            +
                             items:
         | 
| 134 | 
            +
                               type: string
         | 
| 135 | 
            +
            delete_webhook:
         | 
| 136 | 
            +
              type: object
         | 
| 137 | 
            +
              required:
         | 
| 138 | 
            +
                - status
         | 
| 139 | 
            +
              properties:
         | 
| 140 | 
            +
                status:
         | 
| 141 | 
            +
                  type: string
         | 
    
        data/examples/api/domain.rb
    CHANGED
    
    | @@ -1,18 +1,25 @@ | |
| 1 1 | 
             
            require 'unione-ruby'
         | 
| 2 2 |  | 
| 3 | 
            -
            unione = UniOne::Client.new( | 
| 3 | 
            +
            unione = UniOne::Client.new(
         | 
| 4 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 5 | 
            +
              lang: 'en',
         | 
| 6 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 7 | 
            +
            )
         | 
| 4 8 |  | 
| 5 9 | 
             
            # Generate/get DNS records for domain verification and DKIM signing
         | 
| 6 | 
            -
            response = unione.get_dns_records( | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
            puts response.headers
         | 
| 10 | 
            +
            response = unione.get_dns_records(
         | 
| 11 | 
            +
              domain: 'example.com'
         | 
| 12 | 
            +
            )
         | 
| 10 13 |  | 
| 11 14 | 
             
            # Validate domain verification record before use
         | 
| 12 | 
            -
            response = unione.validate_verification_record( | 
| 15 | 
            +
            response = unione.validate_verification_record(
         | 
| 16 | 
            +
              domain: 'example.com'
         | 
| 17 | 
            +
            )
         | 
| 13 18 |  | 
| 14 19 | 
             
            # Validate DKIM signature before sending
         | 
| 15 | 
            -
            response = unione.validate_dkim( | 
| 20 | 
            +
            response = unione.validate_dkim(
         | 
| 21 | 
            +
              domain: 'example.com'
         | 
| 22 | 
            +
            )
         | 
| 16 23 |  | 
| 17 24 | 
             
            # Get a list of your domains and their verification/DKIM statuses
         | 
| 18 25 | 
             
            response = unione.list_domains
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            require 'unione-ruby'
         | 
| 2 | 
            +
            require 'json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            unione = UniOne::Client.new(
         | 
| 5 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 6 | 
            +
              lang: 'en',
         | 
| 7 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 8 | 
            +
            )
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            # Send email with attachments
         | 
| 11 | 
            +
            message = {}
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            message[:subject] = 'Subject'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            message[:from_email] = 'test@qadns.net'
         | 
| 16 | 
            +
            message[:from_name] = 'userName'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            message[:body] = { html: '<b>Hello {{substitutionName}}</b>' }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            message[:recipients] = []
         | 
| 21 | 
            +
            message[:recipients] << { email: 'recipient@example.com' }
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            message[:attachments] = []
         | 
| 24 | 
            +
            message[:attachments] << { type: 'text/plain', name: 'myfile.txt', content: 'ZXhhbXBsZSBmaWxl' }
         | 
| 25 | 
            +
            message[:inline_attachments] = []
         | 
| 26 | 
            +
            message[:inline_attachments] << { type: 'image/png', name: 'IMAGECID', content: 'iVBORw0KGgo' }
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            response = unione.send_email(message: message)
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            require 'unione-ruby'
         | 
| 2 | 
            +
            require 'json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            unione = UniOne::Client.new(
         | 
| 5 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 6 | 
            +
              lang: 'en',
         | 
| 7 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 8 | 
            +
            )
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            # Send email with multiple recipients
         | 
| 11 | 
            +
            message = {}
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            message[:subject] = 'Subject'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            message[:from_email] = 'test@qadns.net'
         | 
| 16 | 
            +
            message[:from_name] = 'userName'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            message[:body] = { html: '<b>Hello {{substitutionName}}</b>' }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            message[:recipients] = []
         | 
| 21 | 
            +
            message[:recipients] << { email: 'recipient1@example.com' }
         | 
| 22 | 
            +
            message[:recipients] << { email: 'recipient2@example.com' }
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            response = unione.send_email(message: message)
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            require 'unione-ruby'
         | 
| 2 | 
            +
            require 'json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            unione = UniOne::Client.new(
         | 
| 5 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 6 | 
            +
              lang: 'en',
         | 
| 7 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 8 | 
            +
            )
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            message = {}
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            message[:subject] = 'Subject'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            message[:from_email] = 'test@qadns.net'
         | 
| 15 | 
            +
            message[:from_name] = 'userName'
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            message[:body] = { plaintext: 'Hello' }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            # HTML body
         | 
| 20 | 
            +
            message[:body] = { html: '<b>Hello {{substitutionName}}</b>' }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            message[:recipients] = []
         | 
| 23 | 
            +
            message[:recipients] << { email: 'recipient@example.com' }
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            response = unione.send_email(message: message)
         | 
| @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            require 'unione-ruby'
         | 
| 2 | 
            +
            require 'json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            unione = UniOne::Client.new(
         | 
| 5 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 6 | 
            +
              lang: 'en',
         | 
| 7 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 8 | 
            +
            )
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            message = {}
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            message[:subject] = 'Subject'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            message[:from_email] = 'test@qadns.net'
         | 
| 15 | 
            +
            message[:from_name] = 'userName'
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            message[:body] = { plaintext: 'Hello' }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            message[:recipients] = []
         | 
| 20 | 
            +
            message[:recipients] << { email: 'recipient@example.com' }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            message[:global_metadata] = { key: 'val' }
         | 
| 23 | 
            +
            message[:headers] = { 'X-ReplyTo' => 'reply@qadns.net' }
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            message[:track_links] = 1
         | 
| 26 | 
            +
            message[:track_read] = 1
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            # Should have permissions to use this option
         | 
| 29 | 
            +
            message[:skip_unsubscribe] = 1
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            # Language of the unsubscribe footer and unsubscribe page
         | 
| 32 | 
            +
            message[:global_language] = 'en'
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            message[:options] = {
         | 
| 35 | 
            +
              unsubscribe_url: 'https://domain.com/unsubscribe',
         | 
| 36 | 
            +
              send_at: Time.now, # Or String: '2021-11-19 10:00:00'
         | 
| 37 | 
            +
              custom_backend_id: 1, # Need permission
         | 
| 38 | 
            +
              smtp_pool_id: 1       # Need permission
         | 
| 39 | 
            +
            }
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            response = unione.send_email(message: message)
         | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            require 'unione-ruby'
         | 
| 2 | 
            +
            require 'json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            unione = UniOne::Client.new(
         | 
| 5 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 6 | 
            +
              lang: 'en',
         | 
| 7 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 8 | 
            +
            )
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            response = unione.subscribe_email(
         | 
| 11 | 
            +
              from_email: 'from@qadns.net',
         | 
| 12 | 
            +
              from_name: 'Example Sender',
         | 
| 13 | 
            +
              to_email: 'blackhole@example.com'
         | 
| 14 | 
            +
            )
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require 'unione-ruby'
         | 
| 2 | 
            +
            require 'json'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            unione = UniOne::Client.new(
         | 
| 5 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 6 | 
            +
              lang: 'en',
         | 
| 7 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 8 | 
            +
            )
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            # Send email using template
         | 
| 11 | 
            +
            message = {}
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            message[:subject] = 'Subject'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            message[:from_email] = 'test@qadns.net'
         | 
| 16 | 
            +
            message[:from_name] = 'userName'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            message[:recipients] = []
         | 
| 19 | 
            +
            message[:recipients] << { email: 'recipient@example.com' }
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            message[:template_engine] = 'simple'
         | 
| 22 | 
            +
            message[:template_id] = 'template_id'
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            message[:tags] = ['string1']
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            response = unione.send_email(message: message)
         | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            require 'unione-ruby'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            unione = UniOne::Client.new(
         | 
| 4 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 5 | 
            +
              lang: 'en',
         | 
| 6 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 7 | 
            +
            )
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # Create event dump
         | 
| 10 | 
            +
            filter = {
         | 
| 11 | 
            +
              job_id: '1ZymBc-00041N-9X',
         | 
| 12 | 
            +
              status: 'sent',
         | 
| 13 | 
            +
              delivery_status: 'err_user_unknown',
         | 
| 14 | 
            +
              email: 'david@example.org',
         | 
| 15 | 
            +
              email_from: 'sender@example.com',
         | 
| 16 | 
            +
              domain: 'example.org',
         | 
| 17 | 
            +
              campaign_id: 'c77f4f4e-3561-49f7-9f07-c35be01b4f43'
         | 
| 18 | 
            +
            }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            response = unione.create_event_dump(
         | 
| 21 | 
            +
              start_time: Time.now, # Or String: '2022-07-20 00:00:00'
         | 
| 22 | 
            +
              end_time: Time.now, # Or String: '2022-07-21 00:00:00'
         | 
| 23 | 
            +
              limit: 50,
         | 
| 24 | 
            +
              all_projects: false,
         | 
| 25 | 
            +
              filter: filter,
         | 
| 26 | 
            +
              delimiter: ';',
         | 
| 27 | 
            +
              format: 'csv'
         | 
| 28 | 
            +
            )
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            # Get id of created event dump
         | 
| 31 | 
            +
            dump_id = response.body.dump_id
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            # Get event dump
         | 
| 34 | 
            +
            response = unione.get_event_dump(
         | 
| 35 | 
            +
              dump_id: dump_id
         | 
| 36 | 
            +
            )
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            # List event dumps
         | 
| 39 | 
            +
            response = unione.list_event_dumps
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            # Delete event dump
         | 
| 42 | 
            +
            response = unione.delete_event_dump(
         | 
| 43 | 
            +
              dump_id: dump_id
         | 
| 44 | 
            +
            )
         | 
    
        data/examples/api/project.rb
    CHANGED
    
    | @@ -1,20 +1,44 @@ | |
| 1 1 | 
             
            require 'unione-ruby'
         | 
| 2 2 |  | 
| 3 | 
            +
            unione = UniOne::Client.new(
         | 
| 4 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 5 | 
            +
              lang: 'en',
         | 
| 6 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 7 | 
            +
            )
         | 
| 8 | 
            +
             | 
| 3 9 | 
             
            # Create project
         | 
| 4 | 
            -
            unione = UniOne::Client.new(data_center: 'eu1', lang: 'en', api_key: ENV['UNIONE_API_KEY'])
         | 
| 5 10 | 
             
            response = unione.create_project(
         | 
| 6 | 
            -
              { | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 11 | 
            +
              project: {
         | 
| 12 | 
            +
                name: 'Project Name',
         | 
| 13 | 
            +
                country: 'ES',
         | 
| 14 | 
            +
                send_enabled: true,
         | 
| 15 | 
            +
                custom_unsubscribe_url_enabled: true # Need permission
         | 
| 16 | 
            +
              }
         | 
| 17 | 
            +
            )
         | 
| 10 18 |  | 
| 11 | 
            -
            #  | 
| 12 | 
            -
             | 
| 13 | 
            -
              {"name" => "Projectname 2", "send_enabled" => true, "custom_unsubscribe_url_enabled" => true})
         | 
| 19 | 
            +
            # Get id of created project
         | 
| 20 | 
            +
            project_id = response.body.project_id
         | 
| 14 21 |  | 
| 15 | 
            -
            #  | 
| 16 | 
            -
            response = unione. | 
| 22 | 
            +
            # Update project
         | 
| 23 | 
            +
            response = unione.update_project(
         | 
| 24 | 
            +
              project_id: project_id,
         | 
| 25 | 
            +
              project: {
         | 
| 26 | 
            +
                name: 'Project Name',
         | 
| 27 | 
            +
                country: 'ES',
         | 
| 28 | 
            +
                send_enabled: true,
         | 
| 29 | 
            +
                custom_unsubscribe_url_enabled: true # Need permission
         | 
| 30 | 
            +
              }
         | 
| 31 | 
            +
            )
         | 
| 17 32 |  | 
| 18 33 | 
             
            # List projects
         | 
| 19 34 | 
             
            response = unione.list_projects
         | 
| 20 | 
            -
             | 
| 35 | 
            +
             | 
| 36 | 
            +
            # List project by id
         | 
| 37 | 
            +
            response = unione.list_projects(
         | 
| 38 | 
            +
              project_id: project_id
         | 
| 39 | 
            +
            )
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            # Delete project
         | 
| 42 | 
            +
            response = unione.delete_project(
         | 
| 43 | 
            +
              project_id: project_id
         | 
| 44 | 
            +
            )
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            require 'unione-ruby'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            unione = UniOne::Client.new(
         | 
| 4 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 5 | 
            +
              lang: 'en',
         | 
| 6 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 7 | 
            +
            )
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # Create suppression
         | 
| 10 | 
            +
            response = unione.set_suppression(
         | 
| 11 | 
            +
              email: 'user@example.com',
         | 
| 12 | 
            +
              cause: 'unsubscribed',
         | 
| 13 | 
            +
              created: Time.now, # Or String: '2021-12-19 10:15:49'
         | 
| 14 | 
            +
            )
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            # Get suppression
         | 
| 17 | 
            +
            response = unione.get_suppression(
         | 
| 18 | 
            +
              email: 'user@example.com',
         | 
| 19 | 
            +
              all_projects: false
         | 
| 20 | 
            +
            )
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            # List suppressions
         | 
| 23 | 
            +
            response = unione.list_suppressions(
         | 
| 24 | 
            +
              cause: 'unsubscribed',
         | 
| 25 | 
            +
              source: 'user',
         | 
| 26 | 
            +
              start_time: Time.now, # Or String: '2021-12-19 10:15:49'
         | 
| 27 | 
            +
              cursor: 'Ajfb6Hvdkn3hdhhvG57xbdufhG5',
         | 
| 28 | 
            +
              limit: 50
         | 
| 29 | 
            +
            )
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            # Delete suppression
         | 
| 32 | 
            +
            response = unione.delete_suppression(
         | 
| 33 | 
            +
              email: 'user@example.com'
         | 
| 34 | 
            +
            )
         | 
    
        data/examples/api/tag.rb
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require 'unione-ruby'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            unione = UniOne::Client.new(
         | 
| 4 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 5 | 
            +
              lang: 'en',
         | 
| 6 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 7 | 
            +
            )
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # List tags
         | 
| 10 | 
            +
            response = unione.list_tags
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            # Delete tag
         | 
| 13 | 
            +
            response = unione.delete_tag(
         | 
| 14 | 
            +
              tag_id: tag_id
         | 
| 15 | 
            +
            )
         | 
    
        data/examples/api/template.rb
    CHANGED
    
    | @@ -1,36 +1,54 @@ | |
| 1 1 | 
             
            require 'unione-ruby'
         | 
| 2 2 | 
             
            require 'json'
         | 
| 3 3 |  | 
| 4 | 
            +
            unione = UniOne::Client.new(
         | 
| 5 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 6 | 
            +
              lang: 'en',
         | 
| 7 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 8 | 
            +
            )
         | 
| 9 | 
            +
             | 
| 4 10 | 
             
            # Set template
         | 
| 5 | 
            -
            template =  | 
| 6 | 
            -
             | 
| 7 | 
            -
            template | 
| 8 | 
            -
            template | 
| 9 | 
            -
            template | 
| 11 | 
            +
            template = {}
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            template[:name] = 'Template Name 1'
         | 
| 14 | 
            +
            template[:editor_type] = 'html'
         | 
| 15 | 
            +
            template[:subject] = 'Email Subject'
         | 
| 16 | 
            +
            template[:template_engine] = 'simple'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            template[:global_substitutions] = {
         | 
| 19 | 
            +
              'someVar' => 'someVal'
         | 
| 20 | 
            +
            }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            template[:from_email] = 'test@example.com'
         | 
| 23 | 
            +
            template[:from_name] = 'userName'
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            template[:headers] = { 'X-ReplyTo' => 'reply@example.com' }
         | 
| 26 | 
            +
            template[:body] = { html: '<b>Hello {{substitutionName}}</b>' }
         | 
| 27 | 
            +
            template[:options] = { unsubscribe_url: 'someurl' }
         | 
| 10 28 |  | 
| 11 | 
            -
            template | 
| 12 | 
            -
            template | 
| 13 | 
            -
            template.body = {html: "<b>Hello {{substitutionName}}</b>"}
         | 
| 29 | 
            +
            template[:attachments] = []
         | 
| 30 | 
            +
            template[:attachments] << { type: 'text/plain', name: 'myfile.txt', content: 'ZXhhbXBsZSBmaWxl' }
         | 
| 14 31 |  | 
| 15 | 
            -
            template | 
| 16 | 
            -
            template | 
| 17 | 
            -
            template.options = {"unsubscribe_url" => "someurl"}
         | 
| 32 | 
            +
            template[:inline_attachments] = []
         | 
| 33 | 
            +
            template[:inline_attachments] << { type: 'image/png', name: 'IMAGECID', content: 'iVBORw0KGgo' }
         | 
| 18 34 |  | 
| 19 | 
            -
             | 
| 35 | 
            +
            response = unione.set_template(template: template)
         | 
| 20 36 |  | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
            puts response.status
         | 
| 24 | 
            -
            puts response.body.to_h
         | 
| 25 | 
            -
            puts response.body.template.id   # Get Id of created template for later referencing
         | 
| 26 | 
            -
            puts response.headers
         | 
| 37 | 
            +
            # Get id of created template
         | 
| 38 | 
            +
            template_id = response.body.template.id
         | 
| 27 39 |  | 
| 28 40 | 
             
            # Get template
         | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 41 | 
            +
            response = unione.get_template(
         | 
| 42 | 
            +
              id: template_id
         | 
| 43 | 
            +
            )
         | 
| 31 44 |  | 
| 32 45 | 
             
            # List templates
         | 
| 33 | 
            -
            response = unione.list_templates( | 
| 46 | 
            +
            response = unione.list_templates(
         | 
| 47 | 
            +
              limit: 50,
         | 
| 48 | 
            +
              offset: 0
         | 
| 49 | 
            +
            )
         | 
| 34 50 |  | 
| 35 51 | 
             
            # Delete template
         | 
| 36 | 
            -
            response = unione.delete_template( | 
| 52 | 
            +
            response = unione.delete_template(
         | 
| 53 | 
            +
              id: template_id
         | 
| 54 | 
            +
            )
         | 
| @@ -1,14 +1,22 @@ | |
| 1 1 | 
             
            require 'unione-ruby'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 3 | 
            +
            unione = UniOne::Client.new(
         | 
| 4 | 
            +
              hostname: 'eu1.unione.io',
         | 
| 5 | 
            +
              lang: 'en',
         | 
| 6 | 
            +
              api_key: ENV['UNIONE_API_KEY']
         | 
| 7 | 
            +
            )
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # Unsubscribe email
         | 
| 10 | 
            +
            response = unione.unsubscribe(
         | 
| 11 | 
            +
              address: 'email@example.com'
         | 
| 12 | 
            +
            )
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            # Check email is unsubscribed
         | 
| 15 | 
            +
            response = unione.check_unsubscribed(
         | 
| 16 | 
            +
              address: 'email@example.com'
         | 
| 17 | 
            +
            )
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            # List unsubscribed emails
         | 
| 20 | 
            +
            response = unione.list_unsubscribed(
         | 
| 21 | 
            +
              date_from: Date.today # Or String: '2019-01-01'
         | 
| 22 | 
            +
            )
         |