intercom 2.5.4 → 3.0.0b1
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/.travis.yml +0 -2
- data/README.md +97 -118
- data/changes.txt +3 -0
- data/intercom.gemspec +1 -1
- data/lib/intercom.rb +13 -153
- data/lib/intercom/admin.rb +0 -2
- data/lib/intercom/api_operations/convert.rb +5 -5
- data/lib/intercom/api_operations/delete.rb +4 -6
- data/lib/intercom/api_operations/find.rb +9 -15
- data/lib/intercom/api_operations/find_all.rb +16 -21
- data/lib/intercom/api_operations/list.rb +4 -10
- data/lib/intercom/api_operations/load.rb +6 -6
- data/lib/intercom/api_operations/save.rb +23 -28
- data/lib/intercom/client.rb +95 -0
- data/lib/intercom/{collection_proxy.rb → client_collection_proxy.rb} +5 -8
- data/lib/intercom/company.rb +0 -16
- data/lib/intercom/contact.rb +0 -11
- data/lib/intercom/conversation.rb +0 -10
- data/lib/intercom/event.rb +0 -2
- data/lib/intercom/extended_api_operations/segments.rb +13 -0
- data/lib/intercom/extended_api_operations/tags.rb +4 -5
- data/lib/intercom/extended_api_operations/users.rb +3 -5
- data/lib/intercom/message.rb +0 -2
- data/lib/intercom/note.rb +1 -10
- data/lib/intercom/options.rb +11 -0
- data/lib/intercom/request.rb +9 -5
- data/lib/intercom/segment.rb +0 -7
- data/lib/intercom/service/admin.rb +14 -0
- data/lib/intercom/service/base_service.rb +21 -0
- data/lib/intercom/service/company.rb +28 -0
- data/lib/intercom/service/contact.rb +22 -0
- data/lib/intercom/service/conversation.rb +31 -0
- data/lib/intercom/service/event.rb +14 -0
- data/lib/intercom/service/message.rb +14 -0
- data/lib/intercom/service/note.rb +22 -0
- data/lib/intercom/service/segment.rb +16 -0
- data/lib/intercom/service/subscription.rb +21 -0
- data/lib/intercom/service/tag.rb +30 -0
- data/lib/intercom/service/user.rb +28 -0
- data/lib/intercom/subscription.rb +0 -8
- data/lib/intercom/tag.rb +0 -16
- data/lib/intercom/user.rb +0 -16
- data/lib/intercom/utils.rb +0 -1
- data/lib/intercom/version.rb +1 -1
- data/spec/spec_helper.rb +117 -0
- data/spec/unit/intercom/admin_spec.rb +11 -4
- data/spec/unit/intercom/client_collection_proxy_spec.rb +35 -0
- data/spec/unit/intercom/client_spec.rb +21 -0
- data/spec/unit/intercom/company_spec.rb +24 -11
- data/spec/unit/intercom/contact_spec.rb +7 -5
- data/spec/unit/intercom/conversation_spec.rb +28 -0
- data/spec/unit/intercom/event_spec.rb +6 -5
- data/spec/unit/intercom/message_spec.rb +9 -8
- data/spec/unit/intercom/note_spec.rb +9 -2
- data/spec/unit/intercom/segment_spec.rb +12 -0
- data/spec/unit/intercom/subscription_spec.rb +7 -5
- data/spec/unit/intercom/tag_spec.rb +13 -7
- data/spec/unit/intercom/user_spec.rb +41 -33
- data/spec/unit/intercom_spec.rb +0 -83
- metadata +30 -20
- data/lib/intercom/api_operations/count.rb +0 -16
- data/lib/intercom/count.rb +0 -21
- data/lib/intercom/extended_api_operations/reply.rb +0 -16
- data/lib/intercom/generic_handlers/base_handler.rb +0 -22
- data/lib/intercom/generic_handlers/count.rb +0 -59
- data/lib/intercom/generic_handlers/tag.rb +0 -71
- data/lib/intercom/generic_handlers/tag_find_all.rb +0 -47
- data/lib/intercom/notification.rb +0 -20
- data/lib/intercom/traits/generic_handler_binding.rb +0 -29
- data/spec/unit/intercom/collection_proxy_spec.rb +0 -34
- data/spec/unit/intercom/notification_spec.rb +0 -68
| @@ -1,12 +1,19 @@ | |
| 1 1 | 
             
            require "spec_helper"
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe "notes" do
         | 
| 4 | 
            +
              let (:client) { Intercom::Client.new(app_id: 'app_id',  api_key: 'api_key') }
         | 
| 5 | 
            +
             | 
| 4 6 | 
             
              it "creates a note" do
         | 
| 5 | 
            -
                 | 
| 6 | 
            -
                note =  | 
| 7 | 
            +
                client.expects(:post).with("/notes", {"body" => "Note to leave on user"}).returns({"body" => "<p>Note to leave on user</p>", "created_at" => 1234567890})
         | 
| 8 | 
            +
                note = client.notes.create("body" => "Note to leave on user")
         | 
| 7 9 | 
             
                note.body.must_equal "<p>Note to leave on user</p>"
         | 
| 8 10 | 
             
              end
         | 
| 9 11 |  | 
| 12 | 
            +
              it 'gets a note' do
         | 
| 13 | 
            +
                client.expects(:get).with("/notes/123", {}).returns({"id" => "123", "body" => "<p>Note to leave on user</p>", "created_at" => 1234567890})
         | 
| 14 | 
            +
                client.notes.find(id: '123')
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 10 17 | 
             
              it "sets/gets allowed keys" do
         | 
| 11 18 | 
             
                params = {"body" => "Note body", "email" => "me@example.com", :user_id => "abc123"}
         | 
| 12 19 | 
             
                note = Intercom::Note.new(params)
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe "Intercom::Segment" do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              let (:client) { Intercom::Client.new(app_id: 'app_id',  api_key: 'api_key') }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              it 'lists segments' do
         | 
| 8 | 
            +
                client.expects(:get).with('/segments', {}).returns(segment_list)
         | 
| 9 | 
            +
                segments = client.segments.all.to_a
         | 
| 10 | 
            +
                segments[0].name.must_equal('Active')
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
            end
         | 
| @@ -1,18 +1,20 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe "Intercom::Subscription" do
         | 
| 4 | 
            +
              let (:client) { Intercom::Client.new(app_id: 'app_id',  api_key: 'api_key') }
         | 
| 5 | 
            +
             | 
| 4 6 | 
             
              it "gets a subscription" do
         | 
| 5 | 
            -
                 | 
| 6 | 
            -
                subscription =  | 
| 7 | 
            +
                client.expects(:get).with("/subscriptions/nsub_123456789", {}).returns(test_subscription)
         | 
| 8 | 
            +
                subscription = client.subscriptions.find(:id => "nsub_123456789")
         | 
| 7 9 | 
             
                subscription.request.topics[0].must_equal "user.created"
         | 
| 8 10 | 
             
                subscription.request.topics[1].must_equal "conversation.user.replied"
         | 
| 9 11 | 
             
              end
         | 
| 10 12 |  | 
| 11 13 | 
             
              it "creates a subscription" do
         | 
| 12 | 
            -
                 | 
| 13 | 
            -
                subscription =  | 
| 14 | 
            +
                client.expects(:post).with("/subscriptions", {'url' => "http://example.com", 'topics' => ["user.created"]}).returns(test_subscription)
         | 
| 15 | 
            +
                subscription = client.subscriptions.create(:url => "http://example.com", :topics => ["user.created"])
         | 
| 14 16 | 
             
                subscription.request.topics[0].must_equal "user.created"
         | 
| 15 17 | 
             
                subscription.request.url.must_equal "http://example.com"
         | 
| 16 18 | 
             
              end
         | 
| 17 19 |  | 
| 18 | 
            -
            end
         | 
| 20 | 
            +
            end
         | 
| @@ -1,23 +1,29 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe "Intercom::Tag" do
         | 
| 4 | 
            +
              let (:client) { Intercom::Client.new(app_id: 'app_id',  api_key: 'api_key') }
         | 
| 5 | 
            +
             | 
| 4 6 | 
             
              it "gets a tag" do
         | 
| 5 | 
            -
                 | 
| 6 | 
            -
                tag =  | 
| 7 | 
            +
                client.expects(:get).with("/tags", {:name => "Test Tag"}).returns(test_tag)
         | 
| 8 | 
            +
                tag = client.tags.find(:name => "Test Tag")
         | 
| 7 9 | 
             
                tag.name.must_equal "Test Tag"
         | 
| 8 10 | 
             
              end
         | 
| 9 11 |  | 
| 10 12 | 
             
              it "creates a tag" do
         | 
| 11 | 
            -
                 | 
| 12 | 
            -
                tag =  | 
| 13 | 
            +
                client.expects(:post).with("/tags", {'name' => "Test Tag"}).returns(test_tag)
         | 
| 14 | 
            +
                tag = client.tags.create(:name => "Test Tag")
         | 
| 13 15 | 
             
                tag.name.must_equal "Test Tag"
         | 
| 14 16 | 
             
              end
         | 
| 15 17 |  | 
| 16 18 | 
             
              it "tags users" do
         | 
| 17 | 
            -
                 | 
| 18 | 
            -
                tag =  | 
| 19 | 
            +
                client.expects(:post).with("/tags", {'name' => "Test Tag", 'users' => [ { user_id: 'abc123' }, { user_id: 'def456' } ], 'tag_or_untag' => 'tag'}).returns(test_tag)
         | 
| 20 | 
            +
                tag = client.tags.tag(:name => "Test Tag", :users => [ { user_id: "abc123" }, { user_id: "def456" } ] )
         | 
| 19 21 | 
             
                tag.name.must_equal "Test Tag"
         | 
| 20 22 | 
             
                tag.tagged_user_count.must_equal 2
         | 
| 21 23 | 
             
              end
         | 
| 22 24 |  | 
| 23 | 
            -
             | 
| 25 | 
            +
              it 'untags users' do
         | 
| 26 | 
            +
                client.expects(:post).with("/tags", {'name' => "Test Tag", 'users' => [ { user_id: 'abc123' }, { user_id: 'def456' } ], 'tag_or_untag' => 'untag'}).returns(test_tag)
         | 
| 27 | 
            +
                client.tags.untag(:name => "Test Tag", :users => [ { user_id: "abc123" }, { user_id: "def456" } ])
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -1,6 +1,8 @@ | |
| 1 1 | 
             
            require "spec_helper"
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe "Intercom::User" do
         | 
| 4 | 
            +
              let (:client) { Intercom::Client.new(app_id: 'app_id',  api_key: 'api_key') }
         | 
| 5 | 
            +
             | 
| 4 6 | 
             
              it "to_hash'es itself" do
         | 
| 5 7 | 
             
                created_at = Time.now
         | 
| 6 8 | 
             
                user = Intercom::User.new(:email => "jim@example.com", :user_id => "12345", :created_at => created_at, :name => "Jim Bob")
         | 
| @@ -77,10 +79,10 @@ describe "Intercom::User" do | |
| 77 79 | 
             
                user.unsubscribed_from_emails.must_equal true
         | 
| 78 80 | 
             
                user.user_agent_data.must_equal "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11"
         | 
| 79 81 | 
             
              end
         | 
| 80 | 
            -
             | 
| 82 | 
            +
             | 
| 81 83 | 
             
              it 'allows update_last_request_at' do
         | 
| 82 | 
            -
                 | 
| 83 | 
            -
                 | 
| 84 | 
            +
                client.expects(:post).with("/users", {"user_id" => "1224242", 'update_last_request_at' => true, "custom_attributes" => {}}).returns({"user_id" => "i-1224242", "last_request_at" => 1414509439})
         | 
| 85 | 
            +
                client.users.create(user_id: '1224242', update_last_request_at: true)
         | 
| 84 86 | 
             
              end
         | 
| 85 87 |  | 
| 86 88 | 
             
              it "allows easy setting of custom data" do
         | 
| @@ -104,7 +106,7 @@ describe "Intercom::User" do | |
| 104 106 |  | 
| 105 107 | 
             
              it "rejects nested data structures in custom_attributes" do
         | 
| 106 108 | 
             
                user = Intercom::User.new()
         | 
| 107 | 
            -
             | 
| 109 | 
            +
             | 
| 108 110 | 
             
                proc { user.custom_attributes["thing"] = [1] }.must_raise(ArgumentError)
         | 
| 109 111 | 
             
                proc { user.custom_attributes["thing"] = {1 => 2} }.must_raise(ArgumentError)
         | 
| 110 112 | 
             
                proc { user.custom_attributes["thing"] = {1 => {2 => 3}} }.must_raise(ArgumentError)
         | 
| @@ -147,58 +149,68 @@ describe "Intercom::User" do | |
| 147 149 | 
             
              end
         | 
| 148 150 |  | 
| 149 151 | 
             
              it "fetches a user" do
         | 
| 150 | 
            -
                 | 
| 151 | 
            -
                user =  | 
| 152 | 
            +
                client.expects(:get).with("/users", {"email" => "bo@example.com"}).returns(test_user)
         | 
| 153 | 
            +
                user = client.users.find("email" => "bo@example.com")
         | 
| 152 154 | 
             
                user.email.must_equal "bob@example.com"
         | 
| 153 155 | 
             
                user.name.must_equal "Joe Schmoe"
         | 
| 154 156 | 
             
                user.session_count.must_equal 123
         | 
| 155 157 | 
             
              end
         | 
| 156 158 |  | 
| 159 | 
            +
              it 'gets users by tag' do
         | 
| 160 | 
            +
                client.expects(:get).with("/users?tag_id=124", {}).returns(page_of_users(false))
         | 
| 161 | 
            +
                client.users.by_tag(124).each { |t| }
         | 
| 162 | 
            +
              end
         | 
| 163 | 
            +
             | 
| 164 | 
            +
              it 'gets users by segment' do
         | 
| 165 | 
            +
                client.expects(:get).with("/users?segment_id=124", {}).returns(page_of_users(false))
         | 
| 166 | 
            +
                client.users.by_segment(124).each { |t| }
         | 
| 167 | 
            +
              end
         | 
| 168 | 
            +
             | 
| 157 169 | 
             
              it "saves a user (always sends custom_attributes)" do
         | 
| 158 170 | 
             
                user = Intercom::User.new("email" => "jo@example.com", :user_id => "i-1224242")
         | 
| 159 | 
            -
                 | 
| 160 | 
            -
                 | 
| 171 | 
            +
                client.expects(:post).with("/users", {"email" => "jo@example.com", "user_id" => "i-1224242", "custom_attributes" => {}}).returns({"email" => "jo@example.com", "user_id" => "i-1224242"})
         | 
| 172 | 
            +
                client.users.save(user)
         | 
| 161 173 | 
             
              end
         | 
| 162 174 |  | 
| 163 175 | 
             
              it "saves a user with a company" do
         | 
| 164 176 | 
             
                user = Intercom::User.new("email" => "jo@example.com", :user_id => "i-1224242", :company => {'company_id' => 6, 'name' => "Intercom"})
         | 
| 165 | 
            -
                 | 
| 166 | 
            -
                 | 
| 177 | 
            +
                client.expects(:post).with("/users", {'custom_attributes' => {}, "user_id" => "i-1224242", "email" => "jo@example.com", "company" => {"company_id" => 6, "name" => "Intercom"}}).returns({"email" => "jo@example.com", "user_id" => "i-1224242"})
         | 
| 178 | 
            +
                client.users.save(user)
         | 
| 167 179 | 
             
              end
         | 
| 168 180 |  | 
| 169 181 | 
             
              it "saves a user with a companies" do
         | 
| 170 182 | 
             
                user = Intercom::User.new("email" => "jo@example.com", :user_id => "i-1224242", :companies => [{'company_id' => 6, 'name' => "Intercom"}])
         | 
| 171 | 
            -
                 | 
| 172 | 
            -
                 | 
| 183 | 
            +
                client.expects(:post).with("/users", {'custom_attributes' => {}, "email" => "jo@example.com", "user_id" => "i-1224242", "companies" => [{"company_id" => 6, "name" => "Intercom"}]}).returns({"email" => "jo@example.com", "user_id" => "i-1224242"})
         | 
| 184 | 
            +
                client.users.save(user)
         | 
| 173 185 | 
             
              end
         | 
| 174 | 
            -
             | 
| 186 | 
            +
             | 
| 175 187 | 
             
              it 'can save a user with a nil email' do
         | 
| 176 188 | 
             
                user = Intercom::User.new("email" => nil, :user_id => "i-1224242", :companies => [{'company_id' => 6, 'name' => "Intercom"}])
         | 
| 177 | 
            -
                 | 
| 178 | 
            -
                 | 
| 189 | 
            +
                client.expects(:post).with("/users", {'custom_attributes' => {}, "email" => nil, "user_id" => "i-1224242", "companies" => [{"company_id" => 6, "name" => "Intercom"}]}).returns({"email" => nil, "user_id" => "i-1224242"})
         | 
| 190 | 
            +
                client.users.save(user)
         | 
| 179 191 | 
             
              end
         | 
| 180 192 |  | 
| 181 193 | 
             
              it "deletes a user" do
         | 
| 182 194 | 
             
                user = Intercom::User.new("id" => "1")
         | 
| 183 | 
            -
                 | 
| 184 | 
            -
                 | 
| 195 | 
            +
                client.expects(:delete).with("/users/1", {}).returns(user)
         | 
| 196 | 
            +
                client.users.delete(user)
         | 
| 185 197 | 
             
              end
         | 
| 186 198 |  | 
| 187 | 
            -
              it "can use  | 
| 188 | 
            -
                 | 
| 189 | 
            -
                user =  | 
| 199 | 
            +
              it "can use client.users.create for convenience" do
         | 
| 200 | 
            +
                client.expects(:post).with("/users", {'custom_attributes' => {}, "email" => "jo@example.com", "user_id" => "i-1224242"}).returns({"email" => "jo@example.com", "user_id" => "i-1224242"})
         | 
| 201 | 
            +
                user = client.users.create("email" => "jo@example.com", :user_id => "i-1224242")
         | 
| 190 202 | 
             
                user.email.must_equal "jo@example.com"
         | 
| 191 203 | 
             
              end
         | 
| 192 204 |  | 
| 193 | 
            -
              it "updates the  | 
| 194 | 
            -
                 | 
| 195 | 
            -
                user =  | 
| 205 | 
            +
              it "updates the user with attributes as set by the server" do
         | 
| 206 | 
            +
                client.expects(:post).with("/users", {"email" => "jo@example.com", "user_id" => "i-1224242", 'custom_attributes' => {}}).returns({"email" => "jo@example.com", "user_id" => "i-1224242", "session_count" => 4})
         | 
| 207 | 
            +
                user = client.users.create("email" => "jo@example.com", :user_id => "i-1224242")
         | 
| 196 208 | 
             
                user.session_count.must_equal 4
         | 
| 197 209 | 
             
              end
         | 
| 198 210 |  | 
| 199 211 | 
             
              it "allows setting dates to nil without converting them to 0" do
         | 
| 200 | 
            -
                 | 
| 201 | 
            -
                user =  | 
| 212 | 
            +
                client.expects(:post).with("/users", {"email" => "jo@example.com", 'custom_attributes' => {}, "remote_created_at" => nil}).returns({"email" => "jo@example.com"})
         | 
| 213 | 
            +
                user = client.users.create("email" => "jo@example.com", "remote_created_at" => nil)
         | 
| 202 214 | 
             
                user.remote_created_at.must_equal nil
         | 
| 203 215 | 
             
              end
         | 
| 204 216 |  | 
| @@ -217,14 +229,10 @@ describe "Intercom::User" do | |
| 217 229 | 
             
                user.new_param.must_equal "some value"
         | 
| 218 230 | 
             
              end
         | 
| 219 231 |  | 
| 220 | 
            -
              it "returns a  | 
| 221 | 
            -
                 | 
| 222 | 
            -
                all =  | 
| 223 | 
            -
                all.must_be_instance_of(Intercom:: | 
| 232 | 
            +
              it "returns a ClientCollectionProxy for all without making any requests" do
         | 
| 233 | 
            +
                client.expects(:execute_request).never
         | 
| 234 | 
            +
                all = client.users.all
         | 
| 235 | 
            +
                all.must_be_instance_of(Intercom::ClientCollectionProxy)
         | 
| 224 236 | 
             
              end
         | 
| 225 237 |  | 
| 226 | 
            -
              it "returns the total number of users" do
         | 
| 227 | 
            -
                Intercom::Count.expects(:user_count).returns('count_info')
         | 
| 228 | 
            -
                Intercom::User.count
         | 
| 229 | 
            -
              end  
         | 
| 230 238 | 
             
            end
         | 
    
        data/spec/unit/intercom_spec.rb
    CHANGED
    
    | @@ -4,87 +4,4 @@ describe Intercom do | |
| 4 4 | 
             
              it "has a version number" do
         | 
| 5 5 | 
             
                Intercom::VERSION.must_match(/\d+\.\d+\.\d+/)
         | 
| 6 6 | 
             
              end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              describe "API" do
         | 
| 9 | 
            -
                before do
         | 
| 10 | 
            -
                  Intercom.app_id = "abc123"
         | 
| 11 | 
            -
                  Intercom.app_api_key = "super-secret-key"
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                it "raises ArgumentError if no app_id or app_api_key specified" do
         | 
| 15 | 
            -
                  Intercom.app_id = nil
         | 
| 16 | 
            -
                  Intercom.app_api_key = nil
         | 
| 17 | 
            -
                  proc { Intercom.target_base_url }.must_raise ArgumentError, "You must set both Intercom.app_id and Intercom.app_api_key to use this client. See https://github.com/intercom/intercom-ruby for usage examples."
         | 
| 18 | 
            -
                end
         | 
| 19 | 
            -
                
         | 
| 20 | 
            -
                it 'raises an Intercom::MultipleMatchingUsers error when receiving a conflict' do
         | 
| 21 | 
            -
                  multiple_matching_error = { 'type' => 'error.list', 'errors' => [{ 'code' => 'conflict', 'message' => 'Multiple existing users match this email address - must be more specific using user_id' }]}
         | 
| 22 | 
            -
                  proc {Intercom::Request.new('/users', :get).raise_application_errors_on_failure(multiple_matching_error, 400)}.must_raise(Intercom::MultipleMatchingUsersError)
         | 
| 23 | 
            -
                end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                it "returns the app_id and app_api_key previously set" do
         | 
| 26 | 
            -
                  Intercom.app_id.must_equal "abc123"
         | 
| 27 | 
            -
                  Intercom.app_api_key.must_equal "super-secret-key"
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                it "defaults to https to api.intercom.io" do
         | 
| 31 | 
            -
                  Intercom.target_base_url.must_equal "https://abc123:super-secret-key@api.intercom.io"
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                it "raises ResourceNotFound if get a 404" do
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                describe "overriding protocol/hostname" do
         | 
| 39 | 
            -
                  before do
         | 
| 40 | 
            -
                    @protocol = Intercom.protocol
         | 
| 41 | 
            -
                    @hostname = Intercom.hostname
         | 
| 42 | 
            -
                    Intercom.endpoints = nil
         | 
| 43 | 
            -
                  end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                  after do
         | 
| 46 | 
            -
                    Intercom.protocol = @protocol
         | 
| 47 | 
            -
                    Intercom.hostname = @hostname
         | 
| 48 | 
            -
                    Intercom.endpoints = ["https://api.intercom.io"]
         | 
| 49 | 
            -
                  end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                  it "allows overriding of the endpoint and protocol" do
         | 
| 52 | 
            -
                    Intercom.protocol = "http"
         | 
| 53 | 
            -
                    Intercom.hostname = "localhost:3000"
         | 
| 54 | 
            -
                    Intercom.target_base_url.must_equal "http://abc123:super-secret-key@localhost:3000"
         | 
| 55 | 
            -
                  end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                  it "prefers endpoints" do
         | 
| 58 | 
            -
                    Intercom.endpoint = "https://localhost:7654"
         | 
| 59 | 
            -
                    Intercom.target_base_url.must_equal "https://abc123:super-secret-key@localhost:7654"
         | 
| 60 | 
            -
                    Intercom.endpoints = unshuffleable_array(["http://example.com","https://localhost:7654"])
         | 
| 61 | 
            -
                    Intercom.target_base_url.must_equal "http://abc123:super-secret-key@example.com"
         | 
| 62 | 
            -
                  end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                  it "has endpoints" do
         | 
| 65 | 
            -
                    Intercom.endpoints.must_equal ["https://api.intercom.io"]
         | 
| 66 | 
            -
                    Intercom.endpoints = ["http://example.com","https://localhost:7654"]
         | 
| 67 | 
            -
                    Intercom.endpoints.must_equal ["http://example.com","https://localhost:7654"]
         | 
| 68 | 
            -
                  end
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                  it "should randomize endpoints if last checked endpoint is > 5 minutes ago" do
         | 
| 71 | 
            -
                    Intercom.instance_variable_set(:@current_endpoint, "http://start")
         | 
| 72 | 
            -
                    Intercom.instance_variable_set(:@endpoints, ["http://alternative"])
         | 
| 73 | 
            -
                    Intercom.instance_variable_set(:@endpoint_randomized_at, Time.now - 120)
         | 
| 74 | 
            -
                    Intercom.current_endpoint.must_equal "http://start"
         | 
| 75 | 
            -
                    Intercom.instance_variable_set(:@endpoint_randomized_at, Time.now - 360)
         | 
| 76 | 
            -
                    Intercom.current_endpoint.must_equal "http://alternative"
         | 
| 77 | 
            -
                    Intercom.instance_variable_get(:@endpoint_randomized_at).to_i.must_be_close_to Time.now.to_i
         | 
| 78 | 
            -
                  end
         | 
| 79 | 
            -
                end
         | 
| 80 | 
            -
              end
         | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
              it "checks for email or user id" do
         | 
| 84 | 
            -
                proc { Intercom.check_required_params("else") }.must_raise ArgumentError, "Expected params Hash, got String"
         | 
| 85 | 
            -
                proc { Intercom.check_required_params(:something => "else") }.must_raise ArgumentError, "Either email or user_id must be specified"
         | 
| 86 | 
            -
                Intercom.check_required_params(:email => "bob@example.com", :something => "else")
         | 
| 87 | 
            -
                Intercom.check_required_params("email" => "bob@example.com", :something => "else")
         | 
| 88 | 
            -
                Intercom.check_required_params(:user_id => "123")
         | 
| 89 | 
            -
              end
         | 
| 90 7 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: intercom
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 3.0.0b1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ben McRedmond
         | 
| @@ -15,7 +15,7 @@ authors: | |
| 15 15 | 
             
            autorequire: 
         | 
| 16 16 | 
             
            bindir: bin
         | 
| 17 17 | 
             
            cert_chain: []
         | 
| 18 | 
            -
            date: 2015- | 
| 18 | 
            +
            date: 2015-06-04 00:00:00.000000000 Z
         | 
| 19 19 | 
             
            dependencies:
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 21 21 | 
             
              name: minitest
         | 
| @@ -116,56 +116,64 @@ files: | |
| 116 116 | 
             
            - lib/intercom.rb
         | 
| 117 117 | 
             
            - lib/intercom/admin.rb
         | 
| 118 118 | 
             
            - lib/intercom/api_operations/convert.rb
         | 
| 119 | 
            -
            - lib/intercom/api_operations/count.rb
         | 
| 120 119 | 
             
            - lib/intercom/api_operations/delete.rb
         | 
| 121 120 | 
             
            - lib/intercom/api_operations/find.rb
         | 
| 122 121 | 
             
            - lib/intercom/api_operations/find_all.rb
         | 
| 123 122 | 
             
            - lib/intercom/api_operations/list.rb
         | 
| 124 123 | 
             
            - lib/intercom/api_operations/load.rb
         | 
| 125 124 | 
             
            - lib/intercom/api_operations/save.rb
         | 
| 126 | 
            -
            - lib/intercom/ | 
| 125 | 
            +
            - lib/intercom/client.rb
         | 
| 126 | 
            +
            - lib/intercom/client_collection_proxy.rb
         | 
| 127 127 | 
             
            - lib/intercom/company.rb
         | 
| 128 128 | 
             
            - lib/intercom/contact.rb
         | 
| 129 129 | 
             
            - lib/intercom/conversation.rb
         | 
| 130 | 
            -
            - lib/intercom/count.rb
         | 
| 131 130 | 
             
            - lib/intercom/errors.rb
         | 
| 132 131 | 
             
            - lib/intercom/event.rb
         | 
| 133 | 
            -
            - lib/intercom/extended_api_operations/ | 
| 132 | 
            +
            - lib/intercom/extended_api_operations/segments.rb
         | 
| 134 133 | 
             
            - lib/intercom/extended_api_operations/tags.rb
         | 
| 135 134 | 
             
            - lib/intercom/extended_api_operations/users.rb
         | 
| 136 | 
            -
            - lib/intercom/generic_handlers/base_handler.rb
         | 
| 137 | 
            -
            - lib/intercom/generic_handlers/count.rb
         | 
| 138 | 
            -
            - lib/intercom/generic_handlers/tag.rb
         | 
| 139 | 
            -
            - lib/intercom/generic_handlers/tag_find_all.rb
         | 
| 140 135 | 
             
            - lib/intercom/lib/dynamic_accessors.rb
         | 
| 141 136 | 
             
            - lib/intercom/lib/dynamic_accessors_on_method_missing.rb
         | 
| 142 137 | 
             
            - lib/intercom/lib/flat_store.rb
         | 
| 143 138 | 
             
            - lib/intercom/lib/typed_json_deserializer.rb
         | 
| 144 139 | 
             
            - lib/intercom/message.rb
         | 
| 145 140 | 
             
            - lib/intercom/note.rb
         | 
| 146 | 
            -
            - lib/intercom/ | 
| 141 | 
            +
            - lib/intercom/options.rb
         | 
| 147 142 | 
             
            - lib/intercom/request.rb
         | 
| 148 143 | 
             
            - lib/intercom/segment.rb
         | 
| 144 | 
            +
            - lib/intercom/service/admin.rb
         | 
| 145 | 
            +
            - lib/intercom/service/base_service.rb
         | 
| 146 | 
            +
            - lib/intercom/service/company.rb
         | 
| 147 | 
            +
            - lib/intercom/service/contact.rb
         | 
| 148 | 
            +
            - lib/intercom/service/conversation.rb
         | 
| 149 | 
            +
            - lib/intercom/service/event.rb
         | 
| 150 | 
            +
            - lib/intercom/service/message.rb
         | 
| 151 | 
            +
            - lib/intercom/service/note.rb
         | 
| 152 | 
            +
            - lib/intercom/service/segment.rb
         | 
| 153 | 
            +
            - lib/intercom/service/subscription.rb
         | 
| 154 | 
            +
            - lib/intercom/service/tag.rb
         | 
| 155 | 
            +
            - lib/intercom/service/user.rb
         | 
| 149 156 | 
             
            - lib/intercom/subscription.rb
         | 
| 150 157 | 
             
            - lib/intercom/tag.rb
         | 
| 151 158 | 
             
            - lib/intercom/traits/api_resource.rb
         | 
| 152 159 | 
             
            - lib/intercom/traits/dirty_tracking.rb
         | 
| 153 | 
            -
            - lib/intercom/traits/generic_handler_binding.rb
         | 
| 154 160 | 
             
            - lib/intercom/traits/incrementable_attributes.rb
         | 
| 155 161 | 
             
            - lib/intercom/user.rb
         | 
| 156 162 | 
             
            - lib/intercom/utils.rb
         | 
| 157 163 | 
             
            - lib/intercom/version.rb
         | 
| 158 164 | 
             
            - spec/spec_helper.rb
         | 
| 159 165 | 
             
            - spec/unit/intercom/admin_spec.rb
         | 
| 160 | 
            -
            - spec/unit/intercom/ | 
| 166 | 
            +
            - spec/unit/intercom/client_collection_proxy_spec.rb
         | 
| 167 | 
            +
            - spec/unit/intercom/client_spec.rb
         | 
| 161 168 | 
             
            - spec/unit/intercom/company_spec.rb
         | 
| 162 169 | 
             
            - spec/unit/intercom/contact_spec.rb
         | 
| 170 | 
            +
            - spec/unit/intercom/conversation_spec.rb
         | 
| 163 171 | 
             
            - spec/unit/intercom/event_spec.rb
         | 
| 164 172 | 
             
            - spec/unit/intercom/lib/flat_store_spec.rb
         | 
| 165 173 | 
             
            - spec/unit/intercom/message_spec.rb
         | 
| 166 174 | 
             
            - spec/unit/intercom/note_spec.rb
         | 
| 167 | 
            -
            - spec/unit/intercom/notification_spec.rb
         | 
| 168 175 | 
             
            - spec/unit/intercom/request_spec.rb
         | 
| 176 | 
            +
            - spec/unit/intercom/segment_spec.rb
         | 
| 169 177 | 
             
            - spec/unit/intercom/subscription_spec.rb
         | 
| 170 178 | 
             
            - spec/unit/intercom/tag_spec.rb
         | 
| 171 179 | 
             
            - spec/unit/intercom/traits/api_resource_spec.rb
         | 
| @@ -183,30 +191,32 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 183 191 | 
             
              requirements:
         | 
| 184 192 | 
             
              - - ">="
         | 
| 185 193 | 
             
                - !ruby/object:Gem::Version
         | 
| 186 | 
            -
                  version: 1. | 
| 194 | 
            +
                  version: 2.1.0
         | 
| 187 195 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 188 196 | 
             
              requirements:
         | 
| 189 | 
            -
              - - " | 
| 197 | 
            +
              - - ">"
         | 
| 190 198 | 
             
                - !ruby/object:Gem::Version
         | 
| 191 | 
            -
                  version:  | 
| 199 | 
            +
                  version: 1.3.1
         | 
| 192 200 | 
             
            requirements: []
         | 
| 193 201 | 
             
            rubyforge_project: intercom
         | 
| 194 | 
            -
            rubygems_version: 2.2. | 
| 202 | 
            +
            rubygems_version: 2.2.2
         | 
| 195 203 | 
             
            signing_key: 
         | 
| 196 204 | 
             
            specification_version: 4
         | 
| 197 205 | 
             
            summary: Ruby bindings for the Intercom API
         | 
| 198 206 | 
             
            test_files:
         | 
| 199 207 | 
             
            - spec/spec_helper.rb
         | 
| 200 208 | 
             
            - spec/unit/intercom/admin_spec.rb
         | 
| 201 | 
            -
            - spec/unit/intercom/ | 
| 209 | 
            +
            - spec/unit/intercom/client_collection_proxy_spec.rb
         | 
| 210 | 
            +
            - spec/unit/intercom/client_spec.rb
         | 
| 202 211 | 
             
            - spec/unit/intercom/company_spec.rb
         | 
| 203 212 | 
             
            - spec/unit/intercom/contact_spec.rb
         | 
| 213 | 
            +
            - spec/unit/intercom/conversation_spec.rb
         | 
| 204 214 | 
             
            - spec/unit/intercom/event_spec.rb
         | 
| 205 215 | 
             
            - spec/unit/intercom/lib/flat_store_spec.rb
         | 
| 206 216 | 
             
            - spec/unit/intercom/message_spec.rb
         | 
| 207 217 | 
             
            - spec/unit/intercom/note_spec.rb
         | 
| 208 | 
            -
            - spec/unit/intercom/notification_spec.rb
         | 
| 209 218 | 
             
            - spec/unit/intercom/request_spec.rb
         | 
| 219 | 
            +
            - spec/unit/intercom/segment_spec.rb
         | 
| 210 220 | 
             
            - spec/unit/intercom/subscription_spec.rb
         | 
| 211 221 | 
             
            - spec/unit/intercom/tag_spec.rb
         | 
| 212 222 | 
             
            - spec/unit/intercom/traits/api_resource_spec.rb
         |