growth_republic_chat_client 0.0.1
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 +7 -0
 - data/.gitignore +22 -0
 - data/Gemfile +2 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +76 -0
 - data/Rakefile +2 -0
 - data/growth_republic_chat_client.gemspec +32 -0
 - data/lib/growth_republic_chat_client.rb +5 -0
 - data/lib/growth_republic_chat_client/paginated_api.rb +2 -0
 - data/lib/growth_republic_chat_client/paginated_api/faraday_parser.rb +17 -0
 - data/lib/growth_republic_chat_client/paginated_api/her_collection.rb +28 -0
 - data/lib/growth_republic_chat_client/v1.rb +35 -0
 - data/lib/growth_republic_chat_client/v1/models/conversation.rb +29 -0
 - data/lib/growth_republic_chat_client/v1/models/message.rb +17 -0
 - data/lib/growth_republic_chat_client/version.rb +3 -0
 - data/spec/spec_helper.rb +17 -0
 - data/spec/support/examples/collection_pagination.rb +40 -0
 - data/spec/support/request_helpers.rb +26 -0
 - data/spec/v1/models/conversation_spec.rb +76 -0
 - data/spec/v1/models/message_spec.rb +41 -0
 - data/spec/v1/stubs/conversation_messages.json +16 -0
 - data/spec/v1/stubs/created_conversation.json +4 -0
 - data/spec/v1/stubs/invited_people.json +4 -0
 - data/spec/v1/stubs/user_conversations.json +10 -0
 - metadata +206 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5d909a07e69987163778b0e840182a50d9a92d50
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 84d359b4b478f63c83a32e655de949e43d0016b5
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 48a69b319c9f1298cb12fa46328e36e1d48f158daf926a4ed3dcd702d7e73d5c6924754611e1651c2243f911b172525fa8586a48d10a18dfdfffaf0fd92589dc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6b7f2f6a279c503f987be1319acc868aa2a0606d5e6a536ab5b76e5ad615d4c6fc8a81163d04d3841556936c827bb8fc55e6186408ac5e6e60ca8d61af0d1c5c
         
     | 
    
        data/.gitignore
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            *.gem
         
     | 
| 
      
 2 
     | 
    
         
            +
            *.rbc
         
     | 
| 
      
 3 
     | 
    
         
            +
            .bundle
         
     | 
| 
      
 4 
     | 
    
         
            +
            .config
         
     | 
| 
      
 5 
     | 
    
         
            +
            .yardoc
         
     | 
| 
      
 6 
     | 
    
         
            +
            Gemfile.lock
         
     | 
| 
      
 7 
     | 
    
         
            +
            InstalledFiles
         
     | 
| 
      
 8 
     | 
    
         
            +
            _yardoc
         
     | 
| 
      
 9 
     | 
    
         
            +
            coverage
         
     | 
| 
      
 10 
     | 
    
         
            +
            doc/
         
     | 
| 
      
 11 
     | 
    
         
            +
            lib/bundler/man
         
     | 
| 
      
 12 
     | 
    
         
            +
            pkg
         
     | 
| 
      
 13 
     | 
    
         
            +
            rdoc
         
     | 
| 
      
 14 
     | 
    
         
            +
            spec/reports
         
     | 
| 
      
 15 
     | 
    
         
            +
            test/tmp
         
     | 
| 
      
 16 
     | 
    
         
            +
            test/version_tmp
         
     | 
| 
      
 17 
     | 
    
         
            +
            tmp
         
     | 
| 
      
 18 
     | 
    
         
            +
            *.bundle
         
     | 
| 
      
 19 
     | 
    
         
            +
            *.so
         
     | 
| 
      
 20 
     | 
    
         
            +
            *.o
         
     | 
| 
      
 21 
     | 
    
         
            +
            *.a
         
     | 
| 
      
 22 
     | 
    
         
            +
            mkmf.log
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2014 Artur Hebda
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # ChatClient
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            This gem wraps API of Growth Republic's [chat application](https://github.com/growthrepublic/chat). It has been created to make it easier to consume the API across multiple applications. It is very thin and provides two models under first API version. It supports pagination using Kaminari. It has been used from the API written in `Grape`. Check the examples below.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                gem 'growth_republic_chat_client'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                $ gem install growth_republic_chat_client
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            ### Configure location of the Chat API
         
     | 
| 
      
 22 
     | 
    
         
            +
            If you have a Rails application, create `config/initialisers/chat_api.rb` to set the location of the chat API:
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            ```
         
     | 
| 
      
 25 
     | 
    
         
            +
            require 'growth_republic_chat_client/v1'
         
     | 
| 
      
 26 
     | 
    
         
            +
            GrowthRepublicChatClient::V1.configure("<chat_application_url>")
         
     | 
| 
      
 27 
     | 
    
         
            +
            # i.e. "http://127.0.0.1:3001"
         
     | 
| 
      
 28 
     | 
    
         
            +
            ```
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            If you need more advanced configuration of the underlying `Her::API` you can pass a block:
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            ```
         
     | 
| 
      
 33 
     | 
    
         
            +
            require 'growth_republic_chat_client/v1'
         
     | 
| 
      
 34 
     | 
    
         
            +
            GrowthRepublicChatClient::V1.configure("<chat_application_url>") do |api|
         
     | 
| 
      
 35 
     | 
    
         
            +
              api.use Faraday::Adapter::NetHttp
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
| 
      
 37 
     | 
    
         
            +
            ```
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            For more details check out [Her documentation](https://github.com/remiprev/her#usage).
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            ### Conversations
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            ```
         
     | 
| 
      
 44 
     | 
    
         
            +
            # List user's conversations
         
     | 
| 
      
 45 
     | 
    
         
            +
            user_id = 1
         
     | 
| 
      
 46 
     | 
    
         
            +
            GrowthRepublicChatClient::V1::Conversation.for_user(user_id).page(1).per(5)
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            # Start a conversation with people
         
     | 
| 
      
 49 
     | 
    
         
            +
            people_ids = [1, 2]
         
     | 
| 
      
 50 
     | 
    
         
            +
            GrowthRepublicChatClient::V1::Conversation.start(people_ids)
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            # Invite people to a conversation
         
     | 
| 
      
 53 
     | 
    
         
            +
            conversation_id = "53731fbb31373210bc8c0300"
         
     | 
| 
      
 54 
     | 
    
         
            +
            invitee_ids = [3, 4]
         
     | 
| 
      
 55 
     | 
    
         
            +
            GrowthRepublicChatClient::V1::Conversation.invite_people(conversation_id, invitee_ids)
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            # Invite people having a conversation model
         
     | 
| 
      
 58 
     | 
    
         
            +
            invitee_ids = [3, 4]
         
     | 
| 
      
 59 
     | 
    
         
            +
            conversation.invite(invitee_ids)
         
     | 
| 
      
 60 
     | 
    
         
            +
            ```
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            ### Messages
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            ```
         
     | 
| 
      
 65 
     | 
    
         
            +
            # List conversation's messages
         
     | 
| 
      
 66 
     | 
    
         
            +
            conversation_id = "53731fbb31373210bc8c0300"
         
     | 
| 
      
 67 
     | 
    
         
            +
            GrowthRepublicChatClient::V1::Message.for_conversation(conversation_id).page(1).per(5)
         
     | 
| 
      
 68 
     | 
    
         
            +
            ```
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            1. Fork it ( https://github.com/growthrepublic/chat_client/fork )
         
     | 
| 
      
 73 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 74 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 75 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 76 
     | 
    
         
            +
            5. Create a new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'growth_republic_chat_client/version'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 6 
     | 
    
         
            +
              spec.name          = "growth_republic_chat_client"
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.version       = GrowthRepublicChatClient::VERSION
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.authors       = ["Artur Hebda"]
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.email         = ["arturhebda@gmail.com"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.summary       = %[Client for Growth Republic's chat application API.]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.description   = %[
         
     | 
| 
      
 12 
     | 
    
         
            +
                This gem wraps Chat API with easy to use models created by Her.
         
     | 
| 
      
 13 
     | 
    
         
            +
                It passes pagination details received from the Chat API using Kaminari.]
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.homepage      = "https://github.com/growthrepublic/chat_client"
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 20 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_runtime_dependency "her"
         
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_runtime_dependency "faraday"
         
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_runtime_dependency "faraday_middleware"
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_runtime_dependency "kaminari"
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.6"
         
     | 
| 
      
 28 
     | 
    
         
            +
              spec.add_development_dependency "rake"
         
     | 
| 
      
 29 
     | 
    
         
            +
              spec.add_development_dependency "rspec", "~> 3.0.0.rc1"
         
     | 
| 
      
 30 
     | 
    
         
            +
              spec.add_development_dependency "rspec-mocks", "~> 3.0.0.rc1"
         
     | 
| 
      
 31 
     | 
    
         
            +
              spec.add_development_dependency "webmock"
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "faraday"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module GrowthRepublicChatClient
         
     | 
| 
      
 4 
     | 
    
         
            +
              module PaginatedApi
         
     | 
| 
      
 5 
     | 
    
         
            +
                class FaradayParser < Faraday::Response::Middleware
         
     | 
| 
      
 6 
     | 
    
         
            +
                  def on_complete(env)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    pagination = {
         
     | 
| 
      
 8 
     | 
    
         
            +
                      total_count: env.response_headers["x-total"].to_i,
         
     | 
| 
      
 9 
     | 
    
         
            +
                      per_page:    (env.response_headers["x-per-page"] || env.body[:data].count).to_i,
         
     | 
| 
      
 10 
     | 
    
         
            +
                      page:        env.response_headers["x-page"].to_i
         
     | 
| 
      
 11 
     | 
    
         
            +
                    }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    env[:body].merge!(pagination: pagination)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "kaminari"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "kaminari/models/array_extension"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module GrowthRepublicChatClient
         
     | 
| 
      
 5 
     | 
    
         
            +
              module PaginatedApi
         
     | 
| 
      
 6 
     | 
    
         
            +
                module HerCollection
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def self.included(base)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    base.class_eval do
         
     | 
| 
      
 9 
     | 
    
         
            +
                      # support for grape kaminari
         
     | 
| 
      
 10 
     | 
    
         
            +
                      scope :page, ->(page)     { where(page: page || 1) }
         
     | 
| 
      
 11 
     | 
    
         
            +
                      scope :per,  ->(per_page) { where(per_page:  per_page || 50) }
         
     | 
| 
      
 12 
     | 
    
         
            +
                    end
         
     | 
| 
      
 13 
     | 
    
         
            +
                    base.extend(ClassMethods)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  module ClassMethods
         
     | 
| 
      
 17 
     | 
    
         
            +
                    # override private method to return a paginated collection
         
     | 
| 
      
 18 
     | 
    
         
            +
                    def new_collection(parsed_data)
         
     | 
| 
      
 19 
     | 
    
         
            +
                      collection = super(parsed_data)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      pagination = parsed_data[:pagination]
         
     | 
| 
      
 21 
     | 
    
         
            +
                      Kaminari.paginate_array(collection, total_count: pagination[:total_count])
         
     | 
| 
      
 22 
     | 
    
         
            +
                        .page(pagination[:page])
         
     | 
| 
      
 23 
     | 
    
         
            +
                        .per(pagination[:per_page])
         
     | 
| 
      
 24 
     | 
    
         
            +
                    end
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "her"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "faraday"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "faraday_middleware"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require "growth_republic_chat_client/paginated_api"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module GrowthRepublicChatClient
         
     | 
| 
      
 8 
     | 
    
         
            +
              module V1
         
     | 
| 
      
 9 
     | 
    
         
            +
                def self.configure(endpoint, &block)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @api = Her::API.new
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  @api.setup :url => "#{endpoint}/api/v1" do |c|
         
     | 
| 
      
 13 
     | 
    
         
            +
                    yield c if block_given?
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    c.use GrowthRepublicChatClient::PaginatedApi::FaradayParser
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    c.use FaradayMiddleware::EncodeJson
         
     | 
| 
      
 18 
     | 
    
         
            +
                    c.use Her::Middleware::AcceptJSON
         
     | 
| 
      
 19 
     | 
    
         
            +
                    c.use Her::Middleware::FirstLevelParseJSON
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    # inject default adapter unless in test mode
         
     | 
| 
      
 22 
     | 
    
         
            +
                    c.adapter Faraday.default_adapter unless c.builder.handlers.include?(Faraday::Adapter::Test)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  # This is very important. Due to way Her currently works
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # model files need to be required after configuring the API
         
     | 
| 
      
 27 
     | 
    
         
            +
                  require "growth_republic_chat_client/v1/models/conversation"
         
     | 
| 
      
 28 
     | 
    
         
            +
                  require "growth_republic_chat_client/v1/models/message"
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                def self.api
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @api
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module GrowthRepublicChatClient
         
     | 
| 
      
 2 
     | 
    
         
            +
              module V1
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Models
         
     | 
| 
      
 4 
     | 
    
         
            +
                  class Conversation
         
     | 
| 
      
 5 
     | 
    
         
            +
                    include Her::Model
         
     | 
| 
      
 6 
     | 
    
         
            +
                    include GrowthRepublicChatClient::PaginatedApi::HerCollection
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                    uses_api GrowthRepublicChatClient::V1.api
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    attributes :id, :subscribers
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    scope :for_user, ->(id) { where(user_id: id) }
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                    def self.start(people)
         
     | 
| 
      
 15 
     | 
    
         
            +
                      create(people_ids: people)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                    def self.invite_people(id, people)
         
     | 
| 
      
 19 
     | 
    
         
            +
                      new(id: id).invite(people)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                    def invite(people)
         
     | 
| 
      
 23 
     | 
    
         
            +
                      path = [request_path, 'invite'].join('/')
         
     | 
| 
      
 24 
     | 
    
         
            +
                      self.class.post(path, people_ids: people)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module GrowthRepublicChatClient
         
     | 
| 
      
 2 
     | 
    
         
            +
              module V1
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Models
         
     | 
| 
      
 4 
     | 
    
         
            +
                  class Message
         
     | 
| 
      
 5 
     | 
    
         
            +
                    include Her::Model
         
     | 
| 
      
 6 
     | 
    
         
            +
                    include GrowthRepublicChatClient::PaginatedApi::HerCollection
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                    uses_api GrowthRepublicChatClient::V1.api
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    attributes :user_id, :type, :body, :created_at
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    collection_path "conversations/:conversation_id/messages"
         
     | 
| 
      
 13 
     | 
    
         
            +
                    scope :for_conversation, ->(id) { where(conversation_id: id) }
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.join(__dir__, "..", "lib"))
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "webmock/rspec"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require "growth_republic_chat_client/paginated_api"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "growth_republic_chat_client/v1"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            Dir[File.join(__dir__, "support/**/*.rb")].each { |f| require f }
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            GrowthRepublicChatClient::V1.configure(RequestHelpers.api_host)
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 13 
     | 
    
         
            +
              config.raise_errors_for_deprecations!
         
     | 
| 
      
 14 
     | 
    
         
            +
              config.include RequestHelpers
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            WebMock.disable_net_connect!
         
     | 
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Requires:
         
     | 
| 
      
 2 
     | 
    
         
            +
            # - `page` (Integer)
         
     | 
| 
      
 3 
     | 
    
         
            +
            # - `per_page` (Integer)
         
     | 
| 
      
 4 
     | 
    
         
            +
            # - `endpoint` (String) url for endpoint to be stubbed
         
     | 
| 
      
 5 
     | 
    
         
            +
            # - `response_body` (String) response body to be returned by the `endpoint`
         
     | 
| 
      
 6 
     | 
    
         
            +
            # - `collection` (Her::Model) scope provided by Her or the model class
         
     | 
| 
      
 7 
     | 
    
         
            +
            shared_examples_for "collection pagination" do
         
     | 
| 
      
 8 
     | 
    
         
            +
              let(:total_pages) { 2 }
         
     | 
| 
      
 9 
     | 
    
         
            +
              let(:total_count) { total_pages * per_page }
         
     | 
| 
      
 10 
     | 
    
         
            +
              let(:response_headers) do
         
     | 
| 
      
 11 
     | 
    
         
            +
                {
         
     | 
| 
      
 12 
     | 
    
         
            +
                  "Content-Type" => "application/json",
         
     | 
| 
      
 13 
     | 
    
         
            +
                  "X-Page"       => page,
         
     | 
| 
      
 14 
     | 
    
         
            +
                  "X-Total"      => total_count,
         
     | 
| 
      
 15 
     | 
    
         
            +
                  "X-Total-Pages"=> total_pages,
         
     | 
| 
      
 16 
     | 
    
         
            +
                  "X-Next-Page"  => page + 1,
         
     | 
| 
      
 17 
     | 
    
         
            +
                  "X-Per-Page"   => per_page
         
     | 
| 
      
 18 
     | 
    
         
            +
                }
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              it "paginates collection" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                stub_request(:get, endpoint)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  .to_return(
         
     | 
| 
      
 24 
     | 
    
         
            +
                    status:  200,
         
     | 
| 
      
 25 
     | 
    
         
            +
                    body:    response_body,
         
     | 
| 
      
 26 
     | 
    
         
            +
                    headers: response_headers)
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                results = request_paginated(collection,
         
     | 
| 
      
 30 
     | 
    
         
            +
                  page: page,
         
     | 
| 
      
 31 
     | 
    
         
            +
                  per:  per_page)
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                expect(results.total_count).to eq total_count
         
     | 
| 
      
 34 
     | 
    
         
            +
                expect(results.current_page).to eq page
         
     | 
| 
      
 35 
     | 
    
         
            +
                expect(results.total_pages).to eq total_pages
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                parsed_all_models = results.all? { |r| r.kind_of?(Her::Model) }
         
     | 
| 
      
 38 
     | 
    
         
            +
                expect(parsed_all_models).to be true
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module RequestHelpers
         
     | 
| 
      
 2 
     | 
    
         
            +
              def self.api_host
         
     | 
| 
      
 3 
     | 
    
         
            +
                "http://localhost:3000"
         
     | 
| 
      
 4 
     | 
    
         
            +
              end
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def request_paginated(scope, page: 1, per: 5)
         
     | 
| 
      
 7 
     | 
    
         
            +
                paginated = scope.page(page).per(per)
         
     | 
| 
      
 8 
     | 
    
         
            +
                request_scope(paginated)
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              def api_endpoint(path, version: 'v1')
         
     | 
| 
      
 12 
     | 
    
         
            +
                [RequestHelpers.api_host, 'api', version, path]
         
     | 
| 
      
 13 
     | 
    
         
            +
                  .join('/')
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def request_scope(scope)
         
     | 
| 
      
 17 
     | 
    
         
            +
                scope.fetch
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def stubbed_response_body(name, version: 'v1')
         
     | 
| 
      
 21 
     | 
    
         
            +
                spec_dir  = File.join(__dir__, '..')
         
     | 
| 
      
 22 
     | 
    
         
            +
                stub_file = File.join(spec_dir, version, 'stubs', "#{name}.json")
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                File.read(stub_file)
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe GrowthRepublicChatClient::V1::Models::Conversation, ".for_user" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:user_id)  { 1 }
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:endpoint) { api_endpoint("conversations", version: 'v1') }
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              it "scopes by query attribute :user_id" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                stub_request(:get, "#{endpoint}?user_id=#{user_id}")
         
     | 
| 
      
 9 
     | 
    
         
            +
                  .to_return(status: 200, body: "[]")
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                response = request_scope(described_class.for_user(user_id))
         
     | 
| 
      
 12 
     | 
    
         
            +
                expect(response).to eq []
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            describe GrowthRepublicChatClient::V1::Models::Conversation, ".start" do
         
     | 
| 
      
 17 
     | 
    
         
            +
              let(:people_ids)    { [1, 236] }
         
     | 
| 
      
 18 
     | 
    
         
            +
              let(:endpoint)      { api_endpoint("conversations", version: 'v1') }
         
     | 
| 
      
 19 
     | 
    
         
            +
              let(:response_body) { stubbed_response_body("created_conversation", version: 'v1') }
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              it "starts a conversation with given people" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                stub_request(:post, endpoint)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  .with(body: { people_ids: people_ids }.to_json)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  .to_return(status: 201, body: response_body)
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                conversation = described_class.start(people_ids)
         
     | 
| 
      
 27 
     | 
    
         
            +
                expect(conversation.subscribers).to eq people_ids
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            describe GrowthRepublicChatClient::V1::Models::Conversation, ".invite_people" do
         
     | 
| 
      
 32 
     | 
    
         
            +
              let(:people_ids)          { [1, 236] }
         
     | 
| 
      
 33 
     | 
    
         
            +
              let(:invitee_ids)         { [3] }
         
     | 
| 
      
 34 
     | 
    
         
            +
              let(:create_conversation) { described_class.start(people_ids) }
         
     | 
| 
      
 35 
     | 
    
         
            +
              let(:conversation_id)     { create_conversation.id.to_s }
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              let(:create_endpoint) { api_endpoint("conversations", version: 'v1') }
         
     | 
| 
      
 38 
     | 
    
         
            +
              let(:invite_endpoint) { api_endpoint("conversations/#{conversation_id}/invite", version: 'v1') }
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              before(:each) do
         
     | 
| 
      
 41 
     | 
    
         
            +
                body = stubbed_response_body("created_conversation", version: 'v1')
         
     | 
| 
      
 42 
     | 
    
         
            +
                stub_request(:post, create_endpoint)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  .with(body: { people_ids: people_ids }.to_json)
         
     | 
| 
      
 44 
     | 
    
         
            +
                  .to_return(status: 201, body: body)
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                create_conversation
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              it "invites people to a conversation" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                body = stubbed_response_body("invited_people", version: 'v1')
         
     | 
| 
      
 51 
     | 
    
         
            +
                stub_request(:post, invite_endpoint)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  .with(body: { people_ids: invitee_ids }.to_json)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  .to_return(status: 200, body: body)
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                conversation = described_class.invite_people(conversation_id, invitee_ids)
         
     | 
| 
      
 56 
     | 
    
         
            +
                expect(conversation.subscribers).to eq people_ids | invitee_ids
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
            end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            describe GrowthRepublicChatClient::V1::Models::Conversation, "pagination" do
         
     | 
| 
      
 61 
     | 
    
         
            +
              include_examples "collection pagination" do
         
     | 
| 
      
 62 
     | 
    
         
            +
                let(:user_id)       { 1 }
         
     | 
| 
      
 63 
     | 
    
         
            +
                let(:page)          { 1 }
         
     | 
| 
      
 64 
     | 
    
         
            +
                let(:per_page)      { 2 }
         
     | 
| 
      
 65 
     | 
    
         
            +
                let(:collection)    { described_class.for_user(user_id) }
         
     | 
| 
      
 66 
     | 
    
         
            +
                let(:response_body) { stubbed_response_body("user_conversations", version: 'v1') }
         
     | 
| 
      
 67 
     | 
    
         
            +
                let(:endpoint) do
         
     | 
| 
      
 68 
     | 
    
         
            +
                  params = {
         
     | 
| 
      
 69 
     | 
    
         
            +
                    user_id: user_id,
         
     | 
| 
      
 70 
     | 
    
         
            +
                    page: page,
         
     | 
| 
      
 71 
     | 
    
         
            +
                    per_page: per_page
         
     | 
| 
      
 72 
     | 
    
         
            +
                  }
         
     | 
| 
      
 73 
     | 
    
         
            +
                  api_endpoint("conversations?#{params.to_query}", version: 'v1')
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe GrowthRepublicChatClient::V1::Models::Message, ".for_conversation" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:conversation_id) { "53731fbb31373210bc8c0300" }
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:endpoint_without_redundant_query) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                api_endpoint("conversations/#{conversation_id}/messages", version: 'v1')
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
              let(:endpoint) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                params = { conversation_id: conversation_id }
         
     | 
| 
      
 10 
     | 
    
         
            +
                "#{endpoint_without_redundant_query}?#{params.to_query}"
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              it "scopes conversation" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                stub_request(:get, endpoint)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  .to_return(status: 200, body: "[]")
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                scope = described_class.for_conversation(conversation_id)
         
     | 
| 
      
 18 
     | 
    
         
            +
                response = request_scope(scope)
         
     | 
| 
      
 19 
     | 
    
         
            +
                expect(response).to eq []
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            describe GrowthRepublicChatClient::V1::Models::Message, "pagination" do
         
     | 
| 
      
 24 
     | 
    
         
            +
              include_examples "collection pagination" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                let(:conversation_id) { "53731fbb31373210bc8c0300" }
         
     | 
| 
      
 26 
     | 
    
         
            +
                let(:page)            { 1 }
         
     | 
| 
      
 27 
     | 
    
         
            +
                let(:per_page)        { 2 }
         
     | 
| 
      
 28 
     | 
    
         
            +
                let(:collection)      { described_class.for_conversation(conversation_id) }
         
     | 
| 
      
 29 
     | 
    
         
            +
                let(:response_body)   { stubbed_response_body("conversation_messages", version: 'v1') }
         
     | 
| 
      
 30 
     | 
    
         
            +
                let(:endpoint) do
         
     | 
| 
      
 31 
     | 
    
         
            +
                  params = {
         
     | 
| 
      
 32 
     | 
    
         
            +
                    conversation_id: conversation_id,
         
     | 
| 
      
 33 
     | 
    
         
            +
                    page: page,
         
     | 
| 
      
 34 
     | 
    
         
            +
                    per_page: per_page
         
     | 
| 
      
 35 
     | 
    
         
            +
                  }
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  path = "conversations/#{conversation_id}/messages"
         
     | 
| 
      
 38 
     | 
    
         
            +
                  api_endpoint("#{path}?#{params.to_query}", version: 'v1')
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            [
         
     | 
| 
      
 2 
     | 
    
         
            +
              {
         
     | 
| 
      
 3 
     | 
    
         
            +
                "user_id": 2,
         
     | 
| 
      
 4 
     | 
    
         
            +
                "type": "message",
         
     | 
| 
      
 5 
     | 
    
         
            +
                "body": "last",
         
     | 
| 
      
 6 
     | 
    
         
            +
                "created_at": "2014-05-22T09:47:24.227Z",
         
     | 
| 
      
 7 
     | 
    
         
            +
                "conversation_id": "53731fbb31373210bc8c0300"
         
     | 
| 
      
 8 
     | 
    
         
            +
              },
         
     | 
| 
      
 9 
     | 
    
         
            +
              {
         
     | 
| 
      
 10 
     | 
    
         
            +
                "user_id": 236,
         
     | 
| 
      
 11 
     | 
    
         
            +
                "type": "message",
         
     | 
| 
      
 12 
     | 
    
         
            +
                "body": "first",
         
     | 
| 
      
 13 
     | 
    
         
            +
                "created_at": "2014-05-22T09:47:08.356Z",
         
     | 
| 
      
 14 
     | 
    
         
            +
                "conversation_id": "53731fbb31373210bc8c0300"
         
     | 
| 
      
 15 
     | 
    
         
            +
              }
         
     | 
| 
      
 16 
     | 
    
         
            +
            ]
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,206 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: growth_republic_chat_client
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Artur Hebda
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-05-28 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: her
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: faraday
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: faraday_middleware
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: kaminari
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 74 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '1.6'
         
     | 
| 
      
 76 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 77 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '1.6'
         
     | 
| 
      
 83 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 84 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 85 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 86 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 87 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 88 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 89 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 90 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 91 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 92 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 93 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 94 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 95 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 96 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 97 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 98 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 99 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 100 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 101 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 102 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 103 
     | 
    
         
            +
                    version: 3.0.0.rc1
         
     | 
| 
      
 104 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 105 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 106 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 108 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 109 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 110 
     | 
    
         
            +
                    version: 3.0.0.rc1
         
     | 
| 
      
 111 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 112 
     | 
    
         
            +
              name: rspec-mocks
         
     | 
| 
      
 113 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 114 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 115 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 116 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 117 
     | 
    
         
            +
                    version: 3.0.0.rc1
         
     | 
| 
      
 118 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 119 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 120 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 121 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 122 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 123 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 124 
     | 
    
         
            +
                    version: 3.0.0.rc1
         
     | 
| 
      
 125 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 126 
     | 
    
         
            +
              name: webmock
         
     | 
| 
      
 127 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 128 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 129 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 130 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 131 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 132 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 133 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 134 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 135 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 136 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 137 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 138 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 139 
     | 
    
         
            +
            description: |2-
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
                  This gem wraps Chat API with easy to use models created by Her.
         
     | 
| 
      
 142 
     | 
    
         
            +
                  It passes pagination details received from the Chat API using Kaminari.
         
     | 
| 
      
 143 
     | 
    
         
            +
            email:
         
     | 
| 
      
 144 
     | 
    
         
            +
            - arturhebda@gmail.com
         
     | 
| 
      
 145 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 146 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 147 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 148 
     | 
    
         
            +
            files:
         
     | 
| 
      
 149 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 150 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 151 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 152 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 153 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 154 
     | 
    
         
            +
            - growth_republic_chat_client.gemspec
         
     | 
| 
      
 155 
     | 
    
         
            +
            - lib/growth_republic_chat_client.rb
         
     | 
| 
      
 156 
     | 
    
         
            +
            - lib/growth_republic_chat_client/paginated_api.rb
         
     | 
| 
      
 157 
     | 
    
         
            +
            - lib/growth_republic_chat_client/paginated_api/faraday_parser.rb
         
     | 
| 
      
 158 
     | 
    
         
            +
            - lib/growth_republic_chat_client/paginated_api/her_collection.rb
         
     | 
| 
      
 159 
     | 
    
         
            +
            - lib/growth_republic_chat_client/v1.rb
         
     | 
| 
      
 160 
     | 
    
         
            +
            - lib/growth_republic_chat_client/v1/models/conversation.rb
         
     | 
| 
      
 161 
     | 
    
         
            +
            - lib/growth_republic_chat_client/v1/models/message.rb
         
     | 
| 
      
 162 
     | 
    
         
            +
            - lib/growth_republic_chat_client/version.rb
         
     | 
| 
      
 163 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 164 
     | 
    
         
            +
            - spec/support/examples/collection_pagination.rb
         
     | 
| 
      
 165 
     | 
    
         
            +
            - spec/support/request_helpers.rb
         
     | 
| 
      
 166 
     | 
    
         
            +
            - spec/v1/models/conversation_spec.rb
         
     | 
| 
      
 167 
     | 
    
         
            +
            - spec/v1/models/message_spec.rb
         
     | 
| 
      
 168 
     | 
    
         
            +
            - spec/v1/stubs/conversation_messages.json
         
     | 
| 
      
 169 
     | 
    
         
            +
            - spec/v1/stubs/created_conversation.json
         
     | 
| 
      
 170 
     | 
    
         
            +
            - spec/v1/stubs/invited_people.json
         
     | 
| 
      
 171 
     | 
    
         
            +
            - spec/v1/stubs/user_conversations.json
         
     | 
| 
      
 172 
     | 
    
         
            +
            homepage: https://github.com/growthrepublic/chat_client
         
     | 
| 
      
 173 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 174 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 175 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 176 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 177 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 178 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 179 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 180 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 181 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 182 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 183 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 184 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 185 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 186 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 187 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 188 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 189 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 190 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 191 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 192 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
      
 193 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 194 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 195 
     | 
    
         
            +
            summary: Client for Growth Republic's chat application API.
         
     | 
| 
      
 196 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 197 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 198 
     | 
    
         
            +
            - spec/support/examples/collection_pagination.rb
         
     | 
| 
      
 199 
     | 
    
         
            +
            - spec/support/request_helpers.rb
         
     | 
| 
      
 200 
     | 
    
         
            +
            - spec/v1/models/conversation_spec.rb
         
     | 
| 
      
 201 
     | 
    
         
            +
            - spec/v1/models/message_spec.rb
         
     | 
| 
      
 202 
     | 
    
         
            +
            - spec/v1/stubs/conversation_messages.json
         
     | 
| 
      
 203 
     | 
    
         
            +
            - spec/v1/stubs/created_conversation.json
         
     | 
| 
      
 204 
     | 
    
         
            +
            - spec/v1/stubs/invited_people.json
         
     | 
| 
      
 205 
     | 
    
         
            +
            - spec/v1/stubs/user_conversations.json
         
     | 
| 
      
 206 
     | 
    
         
            +
            has_rdoc: 
         
     |