sailthru-client 4.1.0 → 4.2.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/.gitignore +1 -0
 - data/CHANGELOG.md +4 -0
 - data/README.md +7 -47
 - data/lib/sailthru/client.rb +19 -3
 - data/lib/sailthru/version.rb +1 -1
 - data/test/sailthru/content_test.rb +159 -19
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4cdd3ac1402c2254ff33c683caca69b2d8b6b0de
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 53c72b791956befc9626a4c9ce7cbe3a817ccca2
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9570a75d2271b75789efafa77c8a61b4baa7028ed7541dcabb9d660671ecce031808454df337660772d9eeb087a9061b2d676176fd04c9dd37b4941b737fdac6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6c38603b1bd381729b0913571e20d5c873c7e4f7c9fec0eaa3c5d6ff0d944b2752db651a41c58f0c004fa2b0242e1c87da31293455c8884286fe9fbb6f0e120f
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,51 +1,11 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
      
 1 
     | 
    
         
            +
            # Sailthru Ruby Library
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            [http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/ruby-gem](http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/ruby-gem/)
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            A simple client library to remotely access the `Sailthru REST API` as per [http://getstarted.sailthru.com/api](http://getstarted.sailthru.com/api)
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            By default, it will make requests in `JSON` format.
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            ## Installation
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                $ gem install sailthru-client
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            ## Requirements
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            This gem supports Ruby 1.9.3 and up.
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            ## Optional parameters for connection/read timeout settings
         
     | 
| 
      
 3 
     | 
    
         
            +
            An [API client library](https://getstarted.sailthru.com/developers/api-client/libraries-overview/) that enables you to access the `Sailthru API` using Ruby.
         
     | 
| 
       19 
4 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       23 
     | 
    
         
            -
            sailthru = Sailthru::Client.new("api-key", "api-secret", "https://api.sailthru.com", nil, nil, 
         
     | 
| 
       24 
     | 
    
         
            -
            			          {:http_read_timeout => 30, :http_ssl_timeout => 30, :http_open_timeout => 30})
         
     | 
| 
       25 
     | 
    
         
            -
            ```
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
            ## Rate Limit Information
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
            The library allows inspection of the 'X-Rate-Limit-*' headers returned by the Sailthru API. The `get_last_rate_limit_info(endpoint, method)` function allows you to retrieve the last known rate limit information for the given endpoint / method combination. It must follow an API call. For example, if you do a `/send POST`, you can follow up with a call to `get_last_rate_limit_info(:send, :post)` as shown below:
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
            ``` ruby
         
     | 
| 
       32 
     | 
    
         
            -
            # make API call as normal
         
     | 
| 
       33 
     | 
    
         
            -
            response = sailthru.send_email template_name, email, {foo: "bar"}
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
            # check rate limit information
         
     | 
| 
       36 
     | 
    
         
            -
            rate_limit_info = sailthru.get_last_rate_limit_info :send, :post
         
     | 
| 
       37 
     | 
    
         
            -
            ```
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
            The return type will be `nil` if there is no rate limit information for the given endpoint / method combination (e.g. if you have not yet made a request to that endpoint). Otherwise, it will be a hash in the following format:
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
            ``` ruby
         
     | 
| 
       42 
     | 
    
         
            -
            {
         
     | 
| 
       43 
     | 
    
         
            -
                limit: 1234, # <Number representing the limit of requests/minute for this action / method combination>
         
     | 
| 
       44 
     | 
    
         
            -
                remaining: 1230, # <Number representing how many requests remain in the current minute>
         
     | 
| 
       45 
     | 
    
         
            -
                reset: 1459381680 # <Number representing the UNIX epoch timestamp of when the next minute starts, and when the rate limit resets>
         
     | 
| 
       46 
     | 
    
         
            -
            }
         
     | 
| 
       47 
     | 
    
         
            -
            ```
         
     | 
| 
      
 5 
     | 
    
         
            +
            For installation instructions, documentation, and examples please visit:
         
     | 
| 
      
 6 
     | 
    
         
            +
            [https://getstarted.sailthru.com/developers/api-client/ruby/](https://getstarted.sailthru.com/developers/api-client/ruby/)
         
     | 
| 
       48 
7 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
            ##  
     | 
| 
      
 8 
     | 
    
         
            +
            ## Running tests
         
     | 
| 
       50 
9 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
            1. `bundle install`
         
     | 
| 
      
 11 
     | 
    
         
            +
            2. `bundle exec rake test`
         
     | 
    
        data/lib/sailthru/client.rb
    CHANGED
    
    | 
         @@ -235,10 +235,10 @@ module Sailthru 
     | 
|
| 
       235 
235 
     | 
    
         
             
                  data[:change_email] = old_email
         
     | 
| 
       236 
236 
     | 
    
         
             
                  api_post(:email, data)
         
     | 
| 
       237 
237 
     | 
    
         
             
                end
         
     | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
       239 
239 
     | 
    
         
             
                # returns:
         
     | 
| 
       240 
240 
     | 
    
         
             
                #   Hash of response data.
         
     | 
| 
       241 
     | 
    
         
            -
                # 
     | 
| 
      
 241 
     | 
    
         
            +
                #
         
     | 
| 
       242 
242 
     | 
    
         
             
                # Get all templates
         
     | 
| 
       243 
243 
     | 
    
         
             
                def get_templates(templates = {})
         
     | 
| 
       244 
244 
     | 
    
         
             
                  api_get(:template, templates)
         
     | 
| 
         @@ -366,7 +366,7 @@ module Sailthru 
     | 
|
| 
       366 
366 
     | 
    
         | 
| 
       367 
367 
     | 
    
         
             
                # params:
         
     | 
| 
       368 
368 
     | 
    
         
             
                #   email, String
         
     | 
| 
       369 
     | 
    
         
            -
                #   items,  
     | 
| 
      
 369 
     | 
    
         
            +
                #   items, Array of Hashes
         
     | 
| 
       370 
370 
     | 
    
         
             
                #   incomplete, Integer
         
     | 
| 
       371 
371 
     | 
    
         
             
                #   message_id, String
         
     | 
| 
       372 
372 
     | 
    
         
             
                #   options, Hash
         
     | 
| 
         @@ -468,6 +468,7 @@ module Sailthru 
     | 
|
| 
       468 
468 
     | 
    
         
             
                  api_get(:stats, data)
         
     | 
| 
       469 
469 
     | 
    
         
             
                end
         
     | 
| 
       470 
470 
     | 
    
         | 
| 
      
 471 
     | 
    
         
            +
                # <b>DEPRECATED:</b> Please use save_content
         
     | 
| 
       471 
472 
     | 
    
         
             
                # params
         
     | 
| 
       472 
473 
     | 
    
         
             
                #   title, String
         
     | 
| 
       473 
474 
     | 
    
         
             
                #   url, String
         
     | 
| 
         @@ -497,6 +498,21 @@ module Sailthru 
     | 
|
| 
       497 
498 
     | 
    
         
             
                  api_post(:content, data)
         
     | 
| 
       498 
499 
     | 
    
         
             
                end
         
     | 
| 
       499 
500 
     | 
    
         | 
| 
      
 501 
     | 
    
         
            +
                # params
         
     | 
| 
      
 502 
     | 
    
         
            +
                #   id, String – An identifier for the item (by default, the item’s URL).
         
     | 
| 
      
 503 
     | 
    
         
            +
                #   options, Hash - Containing any of the parameters described on
         
     | 
| 
      
 504 
     | 
    
         
            +
                #                     https://getstarted.sailthru.com/developers/api/content/#POST_Mode
         
     | 
| 
      
 505 
     | 
    
         
            +
                #
         
     | 
| 
      
 506 
     | 
    
         
            +
                # Push a new piece of content to Sailthru, triggering any applicable alerts.
         
     | 
| 
      
 507 
     | 
    
         
            +
                # http://docs.sailthru.com/api/content
         
     | 
| 
      
 508 
     | 
    
         
            +
                def save_content(id, options)
         
     | 
| 
      
 509 
     | 
    
         
            +
                  data = options
         
     | 
| 
      
 510 
     | 
    
         
            +
                  data[:id] = id
         
     | 
| 
      
 511 
     | 
    
         
            +
                  data[:tags] = data[:tags].join(',') if data[:tags].respond_to?(:join)
         
     | 
| 
      
 512 
     | 
    
         
            +
             
     | 
| 
      
 513 
     | 
    
         
            +
                  api_post(:content, data)
         
     | 
| 
      
 514 
     | 
    
         
            +
                end
         
     | 
| 
      
 515 
     | 
    
         
            +
             
     | 
| 
       500 
516 
     | 
    
         
             
                # params
         
     | 
| 
       501 
517 
     | 
    
         
             
                #   list, String
         
     | 
| 
       502 
518 
     | 
    
         
             
                #
         
     | 
    
        data/lib/sailthru/version.rb
    CHANGED
    
    
| 
         @@ -10,27 +10,167 @@ class ContentTest < Minitest::Test 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  @api_call_url = sailthru_api_call_url(api_url, 'content')
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
                describe '#save_content' do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  describe 'creating a content' do
         
     | 
| 
      
 15 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 16 
     | 
    
         
            +
                      id = 'http://example.com/hello-world'
         
     | 
| 
      
 17 
     | 
    
         
            +
                      options = {
         
     | 
| 
      
 18 
     | 
    
         
            +
                        keys: {
         
     | 
| 
      
 19 
     | 
    
         
            +
                          sku: "123abc"
         
     | 
| 
      
 20 
     | 
    
         
            +
                        },
         
     | 
| 
      
 21 
     | 
    
         
            +
                        title: "Product Name Here",
         
     | 
| 
      
 22 
     | 
    
         
            +
                        description: "Product info text goes here.",
         
     | 
| 
      
 23 
     | 
    
         
            +
                        price: 2099,
         
     | 
| 
      
 24 
     | 
    
         
            +
                        inventory: 42,
         
     | 
| 
      
 25 
     | 
    
         
            +
                        date: "2016-06-20 14:30:00 -0400",
         
     | 
| 
      
 26 
     | 
    
         
            +
                        tags: "blue, jeans, size-m",
         
     | 
| 
      
 27 
     | 
    
         
            +
                        vars: {
         
     | 
| 
      
 28 
     | 
    
         
            +
                          var1: "var 1 value"
         
     | 
| 
      
 29 
     | 
    
         
            +
                        },
         
     | 
| 
      
 30 
     | 
    
         
            +
                        images: {
         
     | 
| 
      
 31 
     | 
    
         
            +
                          full: {
         
     | 
| 
      
 32 
     | 
    
         
            +
                            url: "http://example.com/images/product.jpg"
         
     | 
| 
      
 33 
     | 
    
         
            +
                          }
         
     | 
| 
      
 34 
     | 
    
         
            +
                        },
         
     | 
| 
      
 35 
     | 
    
         
            +
                        site_name: "Store"
         
     | 
| 
      
 36 
     | 
    
         
            +
                      }
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                      stub_post(@api_call_url, 'content_valid.json')
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                      @response = @sailthru_client.save_content(id, options)
         
     | 
| 
      
 41 
     | 
    
         
            +
                      @last_request_params = CGI::parse(FakeWeb.last_request.body)
         
     | 
| 
      
 42 
     | 
    
         
            +
                      @expected_form_params = options.merge({id: id})
         
     | 
| 
      
 43 
     | 
    
         
            +
                    end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                    it 'POST to the correct url' do
         
     | 
| 
      
 46 
     | 
    
         
            +
                      refute_nil @response['content']
         
     | 
| 
      
 47 
     | 
    
         
            +
                    end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    it 'POST with the correct parameters' do
         
     | 
| 
      
 50 
     | 
    
         
            +
                      form_data = JSON.parse(@last_request_params["json"][0], symbolize_names: true)
         
     | 
| 
      
 51 
     | 
    
         
            +
                      assert_equal(form_data, @expected_form_params)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    end
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  describe 'updating content by url and sending tags as array' do
         
     | 
| 
      
 56 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 57 
     | 
    
         
            +
                      id = 'http://example.com/hello-world'
         
     | 
| 
      
 58 
     | 
    
         
            +
                      options = {
         
     | 
| 
      
 59 
     | 
    
         
            +
                        tags: ['tag1', 'tag2'],
         
     | 
| 
      
 60 
     | 
    
         
            +
                      }
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                      stub_post(@api_call_url, 'content_valid.json')
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                      @response = @sailthru_client.save_content(id, options)
         
     | 
| 
      
 65 
     | 
    
         
            +
                      @last_request_params = CGI::parse(FakeWeb.last_request.body)
         
     | 
| 
      
 66 
     | 
    
         
            +
                      @expected_form_params = options.merge({id: id})
         
     | 
| 
      
 67 
     | 
    
         
            +
                    end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                    it 'POST to the correct url' do
         
     | 
| 
      
 70 
     | 
    
         
            +
                      refute_nil @response['content']
         
     | 
| 
      
 71 
     | 
    
         
            +
                    end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                    it 'POST form_data tags as string separated by ","' do
         
     | 
| 
      
 74 
     | 
    
         
            +
                      form_data = JSON.parse(@last_request_params["json"][0], symbolize_names: true)
         
     | 
| 
      
 75 
     | 
    
         
            +
                      assert_equal(form_data[:tags], 'tag1,tag2')
         
     | 
| 
      
 76 
     | 
    
         
            +
                    end
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                  describe 'updating content searching by sku key instead of url' do
         
     | 
| 
      
 80 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 81 
     | 
    
         
            +
                      id = '123abc'
         
     | 
| 
      
 82 
     | 
    
         
            +
                      options = {
         
     | 
| 
      
 83 
     | 
    
         
            +
                        key: 'sku',
         
     | 
| 
      
 84 
     | 
    
         
            +
                        title: "New Product Name Here",
         
     | 
| 
      
 85 
     | 
    
         
            +
                      }
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                      stub_post(@api_call_url, 'content_valid.json')
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                      @response = @sailthru_client.save_content(id, options)
         
     | 
| 
      
 90 
     | 
    
         
            +
                      @last_request_params = CGI::parse(FakeWeb.last_request.body)
         
     | 
| 
      
 91 
     | 
    
         
            +
                      @expected_form_params = options.merge({id: id})
         
     | 
| 
      
 92 
     | 
    
         
            +
                    end
         
     | 
| 
       23 
93 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                   
     | 
| 
      
 94 
     | 
    
         
            +
                    it 'POST to the correct url' do
         
     | 
| 
      
 95 
     | 
    
         
            +
                      refute_nil @response['content']
         
     | 
| 
      
 96 
     | 
    
         
            +
                    end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                    it 'POST with the correct parameters' do
         
     | 
| 
      
 99 
     | 
    
         
            +
                      form_data = JSON.parse(@last_request_params["json"][0], symbolize_names: true)
         
     | 
| 
      
 100 
     | 
    
         
            +
                      assert_equal(form_data, @expected_form_params)
         
     | 
| 
      
 101 
     | 
    
         
            +
                    end
         
     | 
| 
      
 102 
     | 
    
         
            +
                  end
         
     | 
| 
       33 
103 
     | 
    
         
             
                end
         
     | 
| 
       34 
104 
     | 
    
         | 
| 
      
 105 
     | 
    
         
            +
                describe '#push_content: DEPRECATED IN FAVOUR OF save_content' do
         
     | 
| 
      
 106 
     | 
    
         
            +
                  describe 'create content item' do
         
     | 
| 
      
 107 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 108 
     | 
    
         
            +
                      title = 'Product Name here'
         
     | 
| 
      
 109 
     | 
    
         
            +
                      url = "http://example.com/product"
         
     | 
| 
      
 110 
     | 
    
         
            +
                      tags = "blue, jeans, size-m"
         
     | 
| 
      
 111 
     | 
    
         
            +
                      date = nil
         
     | 
| 
      
 112 
     | 
    
         
            +
                      vars = {
         
     | 
| 
      
 113 
     | 
    
         
            +
                        var1: 'var 1 value'
         
     | 
| 
      
 114 
     | 
    
         
            +
                      }
         
     | 
| 
      
 115 
     | 
    
         
            +
                      options = {
         
     | 
| 
      
 116 
     | 
    
         
            +
                        keys: {
         
     | 
| 
      
 117 
     | 
    
         
            +
                          sku: "123abc"
         
     | 
| 
      
 118 
     | 
    
         
            +
                        },
         
     | 
| 
      
 119 
     | 
    
         
            +
                        description: "Product info text goes here.",
         
     | 
| 
      
 120 
     | 
    
         
            +
                        price: 2099,
         
     | 
| 
      
 121 
     | 
    
         
            +
                        inventory: 42,
         
     | 
| 
      
 122 
     | 
    
         
            +
                        images: {
         
     | 
| 
      
 123 
     | 
    
         
            +
                          full: {
         
     | 
| 
      
 124 
     | 
    
         
            +
                            url: "http://example.com/images/product.jpg"
         
     | 
| 
      
 125 
     | 
    
         
            +
                          }
         
     | 
| 
      
 126 
     | 
    
         
            +
                        },
         
     | 
| 
      
 127 
     | 
    
         
            +
                        site_name: "Store"
         
     | 
| 
      
 128 
     | 
    
         
            +
                      }
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
                      stub_post(@api_call_url, 'content_valid.json')
         
     | 
| 
      
 131 
     | 
    
         
            +
                      @response = @sailthru_client.push_content(title, url, date, tags, vars, options)
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                      @last_request_params = CGI::parse(FakeWeb.last_request.body)
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                      @expected_form_params = options.merge({
         
     | 
| 
      
 136 
     | 
    
         
            +
                        title: title,
         
     | 
| 
      
 137 
     | 
    
         
            +
                        url: url,
         
     | 
| 
      
 138 
     | 
    
         
            +
                        vars: vars,
         
     | 
| 
      
 139 
     | 
    
         
            +
                        tags: tags,
         
     | 
| 
      
 140 
     | 
    
         
            +
                      })
         
     | 
| 
      
 141 
     | 
    
         
            +
                    end
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                    it 'POST to the correct url' do
         
     | 
| 
      
 144 
     | 
    
         
            +
                      refute_nil @response['content']
         
     | 
| 
      
 145 
     | 
    
         
            +
                    end
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                    it 'POST with the correct parameters' do
         
     | 
| 
      
 148 
     | 
    
         
            +
                      form_data = JSON.parse(@last_request_params["json"][0], symbolize_names: true)
         
     | 
| 
      
 149 
     | 
    
         
            +
                      assert_equal(form_data, @expected_form_params)
         
     | 
| 
      
 150 
     | 
    
         
            +
                    end
         
     | 
| 
      
 151 
     | 
    
         
            +
                  end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                  describe 'create content item with tags as array' do
         
     | 
| 
      
 154 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 155 
     | 
    
         
            +
                      title = 'Product Name here'
         
     | 
| 
      
 156 
     | 
    
         
            +
                      url = "http://example.com/product"
         
     | 
| 
      
 157 
     | 
    
         
            +
                      tags = ['blue', 'jeans', 'size-m']
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
                      stub_post(@api_call_url, 'content_valid.json')
         
     | 
| 
      
 160 
     | 
    
         
            +
                      @response = @sailthru_client.push_content(title, url, nil, tags)
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
                      @last_request_params = CGI::parse(FakeWeb.last_request.body)
         
     | 
| 
      
 163 
     | 
    
         
            +
                    end
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
                    it 'POST to the correct url' do
         
     | 
| 
      
 166 
     | 
    
         
            +
                      refute_nil @response['content']
         
     | 
| 
      
 167 
     | 
    
         
            +
                    end
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
                    it 'POST form_data tags as string separated by ","' do
         
     | 
| 
      
 170 
     | 
    
         
            +
                      form_data = JSON.parse(@last_request_params["json"][0], symbolize_names: true)
         
     | 
| 
      
 171 
     | 
    
         
            +
                      assert_equal(form_data[:tags], 'blue,jeans,size-m')
         
     | 
| 
      
 172 
     | 
    
         
            +
                    end
         
     | 
| 
      
 173 
     | 
    
         
            +
                  end
         
     | 
| 
      
 174 
     | 
    
         
            +
                end
         
     | 
| 
       35 
175 
     | 
    
         
             
              end
         
     | 
| 
       36 
176 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: sailthru-client
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Prajwal Tuladhar
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2018-06-26 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: json
         
     |