tender 0.3
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.
- data/LICENSE +20 -0
- data/README.md +20 -0
- data/lib/tender/discussion.rb +36 -0
- data/lib/tender/queue.rb +13 -0
- data/lib/tender/version.rb +3 -0
- data/lib/tender.rb +21 -0
- metadata +153 -0
    
        data/LICENSE
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Portions copyright (c) 2011 ZipZoomAuto
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            # Tender API
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            We use this client in our ZipZoomAuto app.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            It's in its infancy, but we'll add it to as we go.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Example Usage
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                discussion_attributes = {
         | 
| 10 | 
            +
                  :body         => "Just wanted to say, your app is amazing.",      
         | 
| 11 | 
            +
                  :title        => "Nice!",
         | 
| 12 | 
            +
                  :author_name  => "Happy User",
         | 
| 13 | 
            +
                  :author_email => "happy@user.com",
         | 
| 14 | 
            +
                  :extras => {
         | 
| 15 | 
            +
                    :company_phone  => "33369"
         | 
| 16 | 
            +
                  }
         | 
| 17 | 
            +
                }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                discussion = Tender::Discussion.create(some_discussion_id, discussion_attributes)
         | 
| 20 | 
            +
                discussion.queue(some_queue_id)
         | 
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            module Tender
         | 
| 2 | 
            +
              class Discussion
         | 
| 3 | 
            +
                def self.create(cat_id, options = {})
         | 
| 4 | 
            +
                  raise ::RuntimeError, ":body is a required option" if options[:body].blank?
         | 
| 5 | 
            +
                  raise ::RuntimeError, "Currently only token authorization is supported. An auth token is required." if Tender.auth_token.blank?
         | 
| 6 | 
            +
                  headers = { 
         | 
| 7 | 
            +
                    'X-Tender-Auth' => Tender.auth_token, 
         | 
| 8 | 
            +
                    'Accept' => 'application/json'
         | 
| 9 | 
            +
                  }  
         | 
| 10 | 
            +
                  url = 'https://api.tenderapp.com/zipzoomauto/'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  resp = HTTParty.post(url + "categories/#{cat_id}/discussions", 
         | 
| 13 | 
            +
                    :headers => headers, 
         | 
| 14 | 
            +
                    :body => {
         | 
| 15 | 
            +
                      :title        => "",
         | 
| 16 | 
            +
                      :skip_spam    => true,
         | 
| 17 | 
            +
                      :public       => false,
         | 
| 18 | 
            +
                      :body         => "",
         | 
| 19 | 
            +
                      :author_email => "support@zipzoomauto.com",
         | 
| 20 | 
            +
                      :author_name  => "Support API"
         | 
| 21 | 
            +
                    }.merge(options),
         | 
| 22 | 
            +
                    :format => :json
         | 
| 23 | 
            +
                  )
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  if resp.code == 201
         | 
| 26 | 
            +
                    resps = class << resp; self; end
         | 
| 27 | 
            +
                    resps.send(:define_method, :queue) do |id|
         | 
| 28 | 
            +
                      Queue.add(resp['queue_href'], id)
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
                    resp
         | 
| 31 | 
            +
                  else
         | 
| 32 | 
            +
                    raise TenderError, "#{resp.flatten.join(" ")}"
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
            end
         | 
    
        data/lib/tender/queue.rb
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            module Tender
         | 
| 2 | 
            +
              class Queue
         | 
| 3 | 
            +
                def self.add(url_template, queue_id)
         | 
| 4 | 
            +
                  headers = { 
         | 
| 5 | 
            +
                    'X-Tender-Auth' => Tender.auth_token, 
         | 
| 6 | 
            +
                    'Accept' => 'application/json'
         | 
| 7 | 
            +
                  }  
         | 
| 8 | 
            +
                  tmpl = Addressable::Template.new(url_template)
         | 
| 9 | 
            +
                  resp = HTTParty.post(tmpl.expand('queue_id' => queue_id).to_s, :headers => headers, :body => "")
         | 
| 10 | 
            +
                  raise TenderError, "Discussion was not added to queue. Response was: #{resp.body}" unless resp.code == 200
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
    
        data/lib/tender.rb
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "active_support"
         | 
| 4 | 
            +
            require "httparty"
         | 
| 5 | 
            +
            require "hashie"
         | 
| 6 | 
            +
            require 'addressable/template'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module Tender
         | 
| 9 | 
            +
              SUPPORT_DISCUSSION = 32544 
         | 
| 10 | 
            +
              MOBILE_QUEUE       = 3866
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              class TenderError < ::RuntimeError; end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              mattr_accessor :auth_token
         | 
| 15 | 
            +
              def self.configure
         | 
| 16 | 
            +
                yield self if block_given?
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            require "tender/discussion"
         | 
| 21 | 
            +
            require "tender/queue"
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,153 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: tender
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              hash: 13
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
              segments: 
         | 
| 7 | 
            +
              - 0
         | 
| 8 | 
            +
              - 3
         | 
| 9 | 
            +
              version: "0.3"
         | 
| 10 | 
            +
            platform: ruby
         | 
| 11 | 
            +
            authors: 
         | 
| 12 | 
            +
            - Nash Kabbara
         | 
| 13 | 
            +
            autorequire: 
         | 
| 14 | 
            +
            bindir: bin
         | 
| 15 | 
            +
            cert_chain: []
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            date: 2011-01-06 00:00:00 -06:00
         | 
| 18 | 
            +
            default_executable: 
         | 
| 19 | 
            +
            dependencies: 
         | 
| 20 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 21 | 
            +
              name: httparty
         | 
| 22 | 
            +
              prerelease: false
         | 
| 23 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 24 | 
            +
                none: false
         | 
| 25 | 
            +
                requirements: 
         | 
| 26 | 
            +
                - - ~>
         | 
| 27 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 28 | 
            +
                    hash: 5
         | 
| 29 | 
            +
                    segments: 
         | 
| 30 | 
            +
                    - 0
         | 
| 31 | 
            +
                    - 4
         | 
| 32 | 
            +
                    - 5
         | 
| 33 | 
            +
                    version: 0.4.5
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              version_requirements: *id001
         | 
| 36 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 37 | 
            +
              name: hashie
         | 
| 38 | 
            +
              prerelease: false
         | 
| 39 | 
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 40 | 
            +
                none: false
         | 
| 41 | 
            +
                requirements: 
         | 
| 42 | 
            +
                - - ~>
         | 
| 43 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 44 | 
            +
                    hash: 11
         | 
| 45 | 
            +
                    segments: 
         | 
| 46 | 
            +
                    - 0
         | 
| 47 | 
            +
                    - 1
         | 
| 48 | 
            +
                    - 8
         | 
| 49 | 
            +
                    version: 0.1.8
         | 
| 50 | 
            +
              type: :runtime
         | 
| 51 | 
            +
              version_requirements: *id002
         | 
| 52 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 53 | 
            +
              name: addressable
         | 
| 54 | 
            +
              prerelease: false
         | 
| 55 | 
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 56 | 
            +
                none: false
         | 
| 57 | 
            +
                requirements: 
         | 
| 58 | 
            +
                - - ~>
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 60 | 
            +
                    hash: 5
         | 
| 61 | 
            +
                    segments: 
         | 
| 62 | 
            +
                    - 2
         | 
| 63 | 
            +
                    - 2
         | 
| 64 | 
            +
                    - 1
         | 
| 65 | 
            +
                    version: 2.2.1
         | 
| 66 | 
            +
              type: :runtime
         | 
| 67 | 
            +
              version_requirements: *id003
         | 
| 68 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 69 | 
            +
              name: activesupport
         | 
| 70 | 
            +
              prerelease: false
         | 
| 71 | 
            +
              requirement: &id004 !ruby/object:Gem::Requirement 
         | 
| 72 | 
            +
                none: false
         | 
| 73 | 
            +
                requirements: 
         | 
| 74 | 
            +
                - - ~>
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 76 | 
            +
                    hash: 17
         | 
| 77 | 
            +
                    segments: 
         | 
| 78 | 
            +
                    - 2
         | 
| 79 | 
            +
                    - 3
         | 
| 80 | 
            +
                    - 9
         | 
| 81 | 
            +
                    version: 2.3.9
         | 
| 82 | 
            +
              type: :runtime
         | 
| 83 | 
            +
              version_requirements: *id004
         | 
| 84 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 85 | 
            +
              name: rspec
         | 
| 86 | 
            +
              prerelease: false
         | 
| 87 | 
            +
              requirement: &id005 !ruby/object:Gem::Requirement 
         | 
| 88 | 
            +
                none: false
         | 
| 89 | 
            +
                requirements: 
         | 
| 90 | 
            +
                - - ~>
         | 
| 91 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 92 | 
            +
                    hash: 27
         | 
| 93 | 
            +
                    segments: 
         | 
| 94 | 
            +
                    - 1
         | 
| 95 | 
            +
                    - 3
         | 
| 96 | 
            +
                    - 0
         | 
| 97 | 
            +
                    version: 1.3.0
         | 
| 98 | 
            +
              type: :development
         | 
| 99 | 
            +
              version_requirements: *id005
         | 
| 100 | 
            +
            description: A simple API wrapper to talk to tender. We use this all over ZipZoomAut's app
         | 
| 101 | 
            +
            email: 
         | 
| 102 | 
            +
            - nash@zipzoomauto.com
         | 
| 103 | 
            +
            executables: []
         | 
| 104 | 
            +
             | 
| 105 | 
            +
            extensions: []
         | 
| 106 | 
            +
             | 
| 107 | 
            +
            extra_rdoc_files: []
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            files: 
         | 
| 110 | 
            +
            - lib/tender/discussion.rb
         | 
| 111 | 
            +
            - lib/tender/queue.rb
         | 
| 112 | 
            +
            - lib/tender/version.rb
         | 
| 113 | 
            +
            - lib/tender.rb
         | 
| 114 | 
            +
            - LICENSE
         | 
| 115 | 
            +
            - README.md
         | 
| 116 | 
            +
            has_rdoc: true
         | 
| 117 | 
            +
            homepage: http://www.zipzoomauto.com
         | 
| 118 | 
            +
            licenses: []
         | 
| 119 | 
            +
             | 
| 120 | 
            +
            post_install_message: 
         | 
| 121 | 
            +
            rdoc_options: []
         | 
| 122 | 
            +
             | 
| 123 | 
            +
            require_paths: 
         | 
| 124 | 
            +
            - lib
         | 
| 125 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 126 | 
            +
              none: false
         | 
| 127 | 
            +
              requirements: 
         | 
| 128 | 
            +
              - - ">="
         | 
| 129 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 130 | 
            +
                  hash: 3
         | 
| 131 | 
            +
                  segments: 
         | 
| 132 | 
            +
                  - 0
         | 
| 133 | 
            +
                  version: "0"
         | 
| 134 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 135 | 
            +
              none: false
         | 
| 136 | 
            +
              requirements: 
         | 
| 137 | 
            +
              - - ">="
         | 
| 138 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 139 | 
            +
                  hash: 23
         | 
| 140 | 
            +
                  segments: 
         | 
| 141 | 
            +
                  - 1
         | 
| 142 | 
            +
                  - 3
         | 
| 143 | 
            +
                  - 6
         | 
| 144 | 
            +
                  version: 1.3.6
         | 
| 145 | 
            +
            requirements: []
         | 
| 146 | 
            +
             | 
| 147 | 
            +
            rubyforge_project: 
         | 
| 148 | 
            +
            rubygems_version: 1.4.1
         | 
| 149 | 
            +
            signing_key: 
         | 
| 150 | 
            +
            specification_version: 3
         | 
| 151 | 
            +
            summary: Talk to tender.
         | 
| 152 | 
            +
            test_files: []
         | 
| 153 | 
            +
             |