intercom 3.6.2 → 3.7.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 +20 -9
- data/changes.txt +17 -0
- data/lib/intercom/api_operations/{delete.rb → archive.rb} +4 -2
- data/lib/intercom/api_operations/request_hard_delete.rb +12 -0
- data/lib/intercom/service/contact.rb +4 -2
- data/lib/intercom/service/subscription.rb +2 -2
- data/lib/intercom/service/tag.rb +1 -1
- data/lib/intercom/service/user.rb +4 -2
- data/lib/intercom/service/visitor.rb +2 -2
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/contact_spec.rb +6 -0
- data/spec/unit/intercom/user_spec.rb +14 -2
- metadata +5 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a6e8da86f1e16e4bce5f0f6fea61822905d6a6d8
         | 
| 4 | 
            +
              data.tar.gz: ccbbde9ad1055d33b6907e5d43157234656b79e8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 434adcd92c200092ff3ed4b2e5909bd56ff46e7732b7497bfd918b591a9a360ece881fb0fef152d04325fb6ecf6e50c8bb4f75d9d15fd5e867e6d10dba6f4098
         | 
| 7 | 
            +
              data.tar.gz: 7363c7f504408438d3fe40556284cdd1a4869d927d3cbe2ffea117186898812eefbb45d4341d6c9f1c49094c5db5eccf366e1a4a19b8030b0079fb12db97afdd
         | 
    
        data/README.md
    CHANGED
    
    | @@ -22,7 +22,7 @@ This version of the gem is compatible with `Ruby 2.1` and above. | |
| 22 22 |  | 
| 23 23 | 
             
            Using bundler:
         | 
| 24 24 |  | 
| 25 | 
            -
                gem 'intercom', '~> 3. | 
| 25 | 
            +
                gem 'intercom', '~> 3.7.0'
         | 
| 26 26 |  | 
| 27 27 | 
             
            ## Basic Usage
         | 
| 28 28 |  | 
| @@ -68,9 +68,13 @@ user = intercom.users.find(user_id: "1") | |
| 68 68 | 
             
            user = intercom.users.find(id: "1")
         | 
| 69 69 | 
             
            # Create a user
         | 
| 70 70 | 
             
            user = intercom.users.create(email: "bob@example.com", name: "Bob Smith", signed_up_at: Time.now.to_i)
         | 
| 71 | 
            -
            #  | 
| 71 | 
            +
            # archive a user
         | 
| 72 72 | 
             
            user = intercom.users.find(id: "1")
         | 
| 73 | 
            -
             | 
| 73 | 
            +
            archived_user = intercom.users.archive(user)
         | 
| 74 | 
            +
            # request a hard delete for a user
         | 
| 75 | 
            +
            (https://developers.intercom.com/intercom-api-reference/reference#delete-users)
         | 
| 76 | 
            +
            user = intercom.users.find(id: "1")
         | 
| 77 | 
            +
            deleted_user = intercom.users.request_hard_delete(user)
         | 
| 74 78 | 
             
            # Update custom_attributes for a user
         | 
| 75 79 | 
             
            user.custom_attributes["average_monthly_spend"] = 1234.56
         | 
| 76 80 | 
             
            intercom.users.save(user)
         | 
| @@ -135,7 +139,7 @@ intercom.companies.all.map {|company| company.name } | |
| 135 139 | 
             
            # Get a list of users in a company by Intercom Company ID
         | 
| 136 140 | 
             
            intercom.companies.users_by_intercom_company_id(company.id)
         | 
| 137 141 | 
             
            # Get a list of users in a company by external company_id
         | 
| 138 | 
            -
            intercom.companies.users_by_company_id(company.company_id) | 
| 142 | 
            +
            intercom.companies.users_by_company_id(company.company_id)
         | 
| 139 143 | 
             
            # Get a large list of companies using scroll
         | 
| 140 144 | 
             
            intercom.companies.scroll.each { |comp| puts comp.name}
         | 
| 141 145 | 
             
            # Please see users scroll for more details of how to use scroll
         | 
| @@ -198,7 +202,7 @@ intercom.conversations.find_all(email: 'joe@example.com', type: 'user', unread: | |
| 198 202 | 
             
            intercom.conversations.find_all(email: 'joe@example.com', type: 'user', unread: true).each {|convo| ... }
         | 
| 199 203 | 
             
            # Iterate over all conversations for a user with their Intercom user ID
         | 
| 200 204 | 
             
            intercom.conversations.find_all(intercom_user_id: '536e564f316c83104c000020', type: 'user').each {|convo| ... }
         | 
| 201 | 
            -
            # Iterate over all conversations for a lead | 
| 205 | 
            +
            # Iterate over all conversations for a lead
         | 
| 202 206 | 
             
            # NOTE: to iterate over a lead's conversations you MUST use their Intercom User ID and type User
         | 
| 203 207 | 
             
            intercom.conversations.find_all(intercom_user_id: lead.id, type: 'user').each {|convo| ... }
         | 
| 204 208 |  | 
| @@ -228,7 +232,7 @@ intercom.conversations.open(id: conversation.id, admin_id: '123') | |
| 228 232 | 
             
            intercom.conversations.close(id: conversation.id, admin_id: '123')
         | 
| 229 233 |  | 
| 230 234 | 
             
            # Assign
         | 
| 231 | 
            -
            # Note: Conversations can be assigned to teams. However, the entity that performs the operation of assigning the conversation has to be an existing teammate. | 
| 235 | 
            +
            # Note: Conversations can be assigned to teams. However, the entity that performs the operation of assigning the conversation has to be an existing teammate.
         | 
| 232 236 | 
             
            #       You can use `intercom.admins.all.each {|a| puts a.inspect if a.type == 'admin' }` to list all of your teammates.
         | 
| 233 237 | 
             
            intercom.conversations.assign(id: conversation.id, admin_id: '123', assignee_id: '124')
         | 
| 234 238 |  | 
| @@ -372,12 +376,19 @@ The metadata key values in the example are treated as follows- | |
| 372 376 | 
             
            ### Contacts
         | 
| 373 377 |  | 
| 374 378 | 
             
            `Contacts` represent logged out users of your application.
         | 
| 379 | 
            +
            Note that `contacts` are referred to as `leads` in the [Intercom](https://developers.intercom.com/intercom-api-reference/reference#leads)
         | 
| 375 380 |  | 
| 376 381 | 
             
            ```ruby
         | 
| 377 382 | 
             
            # Create a contact
         | 
| 378 383 | 
             
            contact = intercom.contacts.create(email: "some_contact@example.com")
         | 
| 379 384 |  | 
| 380 | 
            -
            # Update a contact
         | 
| 385 | 
            +
            # Update a contact (via create method)
         | 
| 386 | 
            +
            # You can update a contact by calling the create method but you MUST provide an id or user_id
         | 
| 387 | 
            +
            # If you just provide an email, for example, it will create a new contact
         | 
| 388 | 
            +
            # See https://developers.intercom.com/intercom-api-reference/reference#update-lead for more detail
         | 
| 389 | 
            +
            contact = intercom.contacts.create(email: "some_contact@example.com", id: "3be0398668071a6bc6850413", name:"update_contact")
         | 
| 390 | 
            +
             | 
| 391 | 
            +
            # Update a contact (via contact object)
         | 
| 381 392 | 
             
            contact.custom_attributes['foo'] = 'bar'
         | 
| 382 393 | 
             
            intercom.contacts.save(contact)
         | 
| 383 394 |  | 
| @@ -410,8 +421,8 @@ contact = intercom.contacts.find(id: "536e564f316c83104c000020") | |
| 410 421 | 
             
            intercom.contacts.convert(contact, Intercom::User.new(email: email))
         | 
| 411 422 | 
             
            # Using find with email will not work here. See https://github.com/intercom/intercom-ruby/issues/419 for more information
         | 
| 412 423 |  | 
| 413 | 
            -
            #  | 
| 414 | 
            -
            intercom.contacts. | 
| 424 | 
            +
            # archive a contact
         | 
| 425 | 
            +
            intercom.contacts.archive(contact)
         | 
| 415 426 |  | 
| 416 427 | 
             
            # Get a large list of contacts using scroll
         | 
| 417 428 | 
             
            intercom.contacts.scroll.each { |lead| puts lead.id}
         | 
    
        data/changes.txt
    CHANGED
    
    | @@ -1,3 +1,20 @@ | |
| 1 | 
            +
            3.7.0
         | 
| 2 | 
            +
            Providing the ability to hard delete users as described here:
         | 
| 3 | 
            +
            https://developers.intercom.com/intercom-api-reference/reference#archive-a-user
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            This chaged the previous delete action to an archive action and added a new hard delete option
         | 
| 6 | 
            +
            You can still use the delete method but it will archive a user, we added an alias for delete.
         | 
| 7 | 
            +
            #442 archiving alias
         | 
| 8 | 
            +
            #410 add ability to hard delete users
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Alos enabling reply to last from the SDK
         | 
| 11 | 
            +
            #443 Residently conversations last reply
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            3.6.2
         | 
| 14 | 
            +
            #384 Add ability to snooze conversation
         | 
| 15 | 
            +
            You can now snooze conversations in your app via:
         | 
| 16 | 
            +
            intercom.conversations.snooze(...)
         | 
| 17 | 
            +
             | 
| 1 18 | 
             
            3.6.1
         | 
| 2 19 | 
             
            #430 Allow all conversations to be listed
         | 
| 3 20 | 
             
            You can now iterate over all conversations for your app via:
         | 
| @@ -2,12 +2,14 @@ require 'intercom/utils' | |
| 2 2 |  | 
| 3 3 | 
             
            module Intercom
         | 
| 4 4 | 
             
              module ApiOperations
         | 
| 5 | 
            -
                module  | 
| 6 | 
            -
                  def  | 
| 5 | 
            +
                module Archive
         | 
| 6 | 
            +
                  def archive(object)
         | 
| 7 7 | 
             
                    collection_name = Utils.resource_class_to_collection_name(collection_class)
         | 
| 8 8 | 
             
                    @client.delete("/#{collection_name}/#{object.id}", {})
         | 
| 9 9 | 
             
                    object
         | 
| 10 10 | 
             
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  alias_method 'delete', 'archive'
         | 
| 11 13 | 
             
                end
         | 
| 12 14 | 
             
              end
         | 
| 13 15 | 
             
            end
         | 
| @@ -6,7 +6,8 @@ require 'intercom/api_operations/find_all' | |
| 6 6 | 
             
            require 'intercom/api_operations/save'
         | 
| 7 7 | 
             
            require 'intercom/api_operations/scroll'
         | 
| 8 8 | 
             
            require 'intercom/api_operations/convert'
         | 
| 9 | 
            -
            require 'intercom/api_operations/ | 
| 9 | 
            +
            require 'intercom/api_operations/archive'
         | 
| 10 | 
            +
            require 'intercom/api_operations/request_hard_delete'
         | 
| 10 11 |  | 
| 11 12 | 
             
            module Intercom
         | 
| 12 13 | 
             
              module Service
         | 
| @@ -18,7 +19,8 @@ module Intercom | |
| 18 19 | 
             
                  include ApiOperations::Save
         | 
| 19 20 | 
             
                  include ApiOperations::Scroll
         | 
| 20 21 | 
             
                  include ApiOperations::Convert
         | 
| 21 | 
            -
                  include ApiOperations:: | 
| 22 | 
            +
                  include ApiOperations::Archive
         | 
| 23 | 
            +
                  include ApiOperations::RequestHardDelete
         | 
| 22 24 |  | 
| 23 25 | 
             
                  def collection_class
         | 
| 24 26 | 
             
                    Intercom::Contact
         | 
| @@ -2,7 +2,7 @@ require 'intercom/api_operations/list' | |
| 2 2 | 
             
            require 'intercom/api_operations/find_all'
         | 
| 3 3 | 
             
            require 'intercom/api_operations/find'
         | 
| 4 4 | 
             
            require 'intercom/api_operations/save'
         | 
| 5 | 
            -
            require 'intercom/api_operations/ | 
| 5 | 
            +
            require 'intercom/api_operations/archive'
         | 
| 6 6 |  | 
| 7 7 | 
             
            module Intercom
         | 
| 8 8 | 
             
              module Service
         | 
| @@ -11,7 +11,7 @@ module Intercom | |
| 11 11 | 
             
                  include ApiOperations::Find
         | 
| 12 12 | 
             
                  include ApiOperations::FindAll
         | 
| 13 13 | 
             
                  include ApiOperations::Save
         | 
| 14 | 
            -
                  include ApiOperations:: | 
| 14 | 
            +
                  include ApiOperations::Archive
         | 
| 15 15 |  | 
| 16 16 | 
             
                  def collection_class
         | 
| 17 17 | 
             
                    Intercom::Subscription
         | 
    
        data/lib/intercom/service/tag.rb
    CHANGED
    
    
| @@ -5,8 +5,9 @@ require 'intercom/api_operations/scroll' | |
| 5 5 | 
             
            require 'intercom/api_operations/find'
         | 
| 6 6 | 
             
            require 'intercom/api_operations/find_all'
         | 
| 7 7 | 
             
            require 'intercom/api_operations/save'
         | 
| 8 | 
            -
            require 'intercom/api_operations/ | 
| 8 | 
            +
            require 'intercom/api_operations/archive'
         | 
| 9 9 | 
             
            require 'intercom/api_operations/bulk/submit'
         | 
| 10 | 
            +
            require 'intercom/api_operations/request_hard_delete'
         | 
| 10 11 | 
             
            require 'intercom/extended_api_operations/tags'
         | 
| 11 12 | 
             
            require 'intercom/extended_api_operations/segments'
         | 
| 12 13 |  | 
| @@ -19,7 +20,8 @@ module Intercom | |
| 19 20 | 
             
                  include ApiOperations::Find
         | 
| 20 21 | 
             
                  include ApiOperations::FindAll
         | 
| 21 22 | 
             
                  include ApiOperations::Save
         | 
| 22 | 
            -
                  include ApiOperations:: | 
| 23 | 
            +
                  include ApiOperations::Archive
         | 
| 24 | 
            +
                  include ApiOperations::RequestHardDelete
         | 
| 23 25 | 
             
                  include ApiOperations::Bulk::Submit
         | 
| 24 26 | 
             
                  include ExtendedApiOperations::Tags
         | 
| 25 27 | 
             
                  include ExtendedApiOperations::Segments
         | 
| @@ -5,7 +5,7 @@ require 'intercom/api_operations/find' | |
| 5 5 | 
             
            require 'intercom/api_operations/find_all'
         | 
| 6 6 | 
             
            require 'intercom/api_operations/save'
         | 
| 7 7 | 
             
            require 'intercom/api_operations/convert'
         | 
| 8 | 
            -
            require 'intercom/api_operations/ | 
| 8 | 
            +
            require 'intercom/api_operations/archive'
         | 
| 9 9 |  | 
| 10 10 | 
             
            module Intercom
         | 
| 11 11 | 
             
              module Service
         | 
| @@ -16,7 +16,7 @@ module Intercom | |
| 16 16 | 
             
                  include ApiOperations::FindAll
         | 
| 17 17 | 
             
                  include ApiOperations::Save
         | 
| 18 18 | 
             
                  include ApiOperations::Convert
         | 
| 19 | 
            -
                  include ApiOperations:: | 
| 19 | 
            +
                  include ApiOperations::Archive
         | 
| 20 20 |  | 
| 21 21 | 
             
                  def collection_class
         | 
| 22 22 | 
             
                    Intercom::Visitor
         | 
    
        data/lib/intercom/version.rb
    CHANGED
    
    
| @@ -50,4 +50,10 @@ describe "Intercom::Contact" do | |
| 50 50 | 
             
                client.contacts.delete(contact)
         | 
| 51 51 | 
             
              end
         | 
| 52 52 |  | 
| 53 | 
            +
              it "sends a request for a hard deletion" do
         | 
| 54 | 
            +
                contact = Intercom::Contact.new("id" => "1")
         | 
| 55 | 
            +
                client.expects(:post).with("/user_delete_requests", {intercom_user_id: "1"}).returns({id: contact.id})
         | 
| 56 | 
            +
                client.contacts.request_hard_delete(contact)
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
             | 
| 53 59 | 
             
            end
         | 
| @@ -218,10 +218,22 @@ describe "Intercom::User" do | |
| 218 218 | 
             
                client.users.save(user)
         | 
| 219 219 | 
             
              end
         | 
| 220 220 |  | 
| 221 | 
            -
              it " | 
| 221 | 
            +
              it "archives a user" do
         | 
| 222 222 | 
             
                user = Intercom::User.new("id" => "1")
         | 
| 223 223 | 
             
                client.expects(:delete).with("/users/1", {}).returns(user)
         | 
| 224 | 
            -
                client.users. | 
| 224 | 
            +
                client.users.archive(user)
         | 
| 225 | 
            +
              end
         | 
| 226 | 
            +
               it "has an alias to archive a user" do
         | 
| 227 | 
            +
                 user = Intercom::User.new("id" => "1")
         | 
| 228 | 
            +
                 client.expects(:delete).with("/users/1", {}).returns(user)
         | 
| 229 | 
            +
                 client.users.delete(user)
         | 
| 230 | 
            +
               end
         | 
| 231 | 
            +
             | 
| 232 | 
            +
             | 
| 233 | 
            +
              it "sends a request for a hard deletion" do
         | 
| 234 | 
            +
                user = Intercom::User.new("id" => "1")
         | 
| 235 | 
            +
                client.expects(:post).with("/user_delete_requests", {intercom_user_id: "1"}).returns({id: user.id})
         | 
| 236 | 
            +
                client.users.request_hard_delete(user)
         | 
| 225 237 | 
             
              end
         | 
| 226 238 |  | 
| 227 239 | 
             
              it "can use client.users.create for convenience" do
         | 
    
        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: 3. | 
| 4 | 
            +
              version: 3.7.0
         | 
| 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: 2018- | 
| 18 | 
            +
            date: 2018-11-16 00:00:00.000000000 Z
         | 
| 19 19 | 
             
            dependencies:
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 21 21 | 
             
              name: minitest
         | 
| @@ -132,14 +132,15 @@ files: | |
| 132 132 | 
             
            - lib/ext/sliceable_hash.rb
         | 
| 133 133 | 
             
            - lib/intercom.rb
         | 
| 134 134 | 
             
            - lib/intercom/admin.rb
         | 
| 135 | 
            +
            - lib/intercom/api_operations/archive.rb
         | 
| 135 136 | 
             
            - lib/intercom/api_operations/bulk/load_error_feed.rb
         | 
| 136 137 | 
             
            - lib/intercom/api_operations/bulk/submit.rb
         | 
| 137 138 | 
             
            - lib/intercom/api_operations/convert.rb
         | 
| 138 | 
            -
            - lib/intercom/api_operations/delete.rb
         | 
| 139 139 | 
             
            - lib/intercom/api_operations/find.rb
         | 
| 140 140 | 
             
            - lib/intercom/api_operations/find_all.rb
         | 
| 141 141 | 
             
            - lib/intercom/api_operations/list.rb
         | 
| 142 142 | 
             
            - lib/intercom/api_operations/load.rb
         | 
| 143 | 
            +
            - lib/intercom/api_operations/request_hard_delete.rb
         | 
| 143 144 | 
             
            - lib/intercom/api_operations/save.rb
         | 
| 144 145 | 
             
            - lib/intercom/api_operations/scroll.rb
         | 
| 145 146 | 
             
            - lib/intercom/client.rb
         | 
| @@ -229,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 229 230 | 
             
                  version: '0'
         | 
| 230 231 | 
             
            requirements: []
         | 
| 231 232 | 
             
            rubyforge_project: intercom
         | 
| 232 | 
            -
            rubygems_version: 2.6.14
         | 
| 233 | 
            +
            rubygems_version: 2.6.14.1
         | 
| 233 234 | 
             
            signing_key: 
         | 
| 234 235 | 
             
            specification_version: 4
         | 
| 235 236 | 
             
            summary: Ruby bindings for the Intercom API
         |