zferral 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +29 -0
- data/Rakefile +43 -0
- data/VERSION +1 -0
- data/lib/zferral.rb +22 -0
- data/lib/zferral/client.rb +34 -0
- data/lib/zferral/errors.rb +13 -0
- data/lib/zferral/resource.rb +136 -0
- data/lib/zferral/resources/campaign.rb +7 -0
- data/lib/zferral/resources/event.rb +33 -0
- data/spec/campaign_spec.rb +38 -0
- data/spec/event_spec.rb +52 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/support/matchers/be.rb +29 -0
- data/spec/vcr_cassettes/campaigns.yml +119 -0
- data/spec/vcr_cassettes/events.yml +207 -0
- data/spec/zferral_spec.rb +26 -0
- data/zferral.gemspec +96 -0
- metadata +240 -0
    
        data/.document
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            --color --format documentation
         | 
    
        data/Gemfile
    ADDED
    
    | @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            source "http://rubygems.org"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            gem "httparty"
         | 
| 4 | 
            +
            gem "json"
         | 
| 5 | 
            +
            gem "hashie"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Add dependencies to develop your gem here.
         | 
| 8 | 
            +
            # Include everything needed to run rake, tests, features, etc.
         | 
| 9 | 
            +
            group :development do
         | 
| 10 | 
            +
              gem "rspec", "~> 2.3.0"
         | 
| 11 | 
            +
              gem "yard", "~> 0.6.0"
         | 
| 12 | 
            +
              gem "bundler", "~> 1.0.0"
         | 
| 13 | 
            +
              gem "jeweler", "~> 1.5.2"
         | 
| 14 | 
            +
              gem "rcov", ">= 0"
         | 
| 15 | 
            +
              gem "vcr"
         | 
| 16 | 
            +
              gem "webmock"
         | 
| 17 | 
            +
            end
         | 
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            GEM
         | 
| 2 | 
            +
              remote: http://rubygems.org/
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                addressable (2.2.3)
         | 
| 5 | 
            +
                crack (0.1.8)
         | 
| 6 | 
            +
                diff-lcs (1.1.2)
         | 
| 7 | 
            +
                git (1.2.5)
         | 
| 8 | 
            +
                hashie (0.4.0)
         | 
| 9 | 
            +
                httparty (0.7.3)
         | 
| 10 | 
            +
                  crack (= 0.1.8)
         | 
| 11 | 
            +
                jeweler (1.5.2)
         | 
| 12 | 
            +
                  bundler (~> 1.0.0)
         | 
| 13 | 
            +
                  git (>= 1.2.5)
         | 
| 14 | 
            +
                  rake
         | 
| 15 | 
            +
                json (1.5.1)
         | 
| 16 | 
            +
                rake (0.8.7)
         | 
| 17 | 
            +
                rcov (0.9.9)
         | 
| 18 | 
            +
                rspec (2.3.0)
         | 
| 19 | 
            +
                  rspec-core (~> 2.3.0)
         | 
| 20 | 
            +
                  rspec-expectations (~> 2.3.0)
         | 
| 21 | 
            +
                  rspec-mocks (~> 2.3.0)
         | 
| 22 | 
            +
                rspec-core (2.3.1)
         | 
| 23 | 
            +
                rspec-expectations (2.3.0)
         | 
| 24 | 
            +
                  diff-lcs (~> 1.1.2)
         | 
| 25 | 
            +
                rspec-mocks (2.3.0)
         | 
| 26 | 
            +
                vcr (1.5.1)
         | 
| 27 | 
            +
                webmock (1.6.2)
         | 
| 28 | 
            +
                  addressable (>= 2.2.2)
         | 
| 29 | 
            +
                  crack (>= 0.1.7)
         | 
| 30 | 
            +
                yard (0.6.4)
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            PLATFORMS
         | 
| 33 | 
            +
              ruby
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            DEPENDENCIES
         | 
| 36 | 
            +
              bundler (~> 1.0.0)
         | 
| 37 | 
            +
              hashie
         | 
| 38 | 
            +
              httparty
         | 
| 39 | 
            +
              jeweler (~> 1.5.2)
         | 
| 40 | 
            +
              json
         | 
| 41 | 
            +
              rcov
         | 
| 42 | 
            +
              rspec (~> 2.3.0)
         | 
| 43 | 
            +
              vcr
         | 
| 44 | 
            +
              webmock
         | 
| 45 | 
            +
              yard (~> 0.6.0)
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright (c) 2011 Michael Klett
         | 
| 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.rdoc
    ADDED
    
    | @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            = zferral API Ruby Wrapper
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Set your API credentials and obtain a Zferral instance
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                zferral = Zferral.new(:subdomain => "foo", :token => "bar")
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Then work with your resources through the instance:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                zferral.campaign.all
         | 
| 10 | 
            +
                # => [<#Zferral::Campaign campaign_status_id=1, commission_approved_callback_url=nil, ...>, ...]
         | 
| 11 | 
            +
                
         | 
| 12 | 
            +
                zferral.event.call(:campaign_id => 1, :revenue => 20.00, :affiliate_id => 300, :customer_id => "john@example.com")
         | 
| 13 | 
            +
                # => <#Zferral::Event commission_sum=2>
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            == Contributing to zferral
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
         | 
| 18 | 
            +
            * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
         | 
| 19 | 
            +
            * Fork the project
         | 
| 20 | 
            +
            * Start a feature/bugfix branch
         | 
| 21 | 
            +
            * Commit and push until you are happy with your contribution
         | 
| 22 | 
            +
            * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
         | 
| 23 | 
            +
            * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            == Copyright
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            Copyright (c) 2011 Michael Klett. See LICENSE.txt for
         | 
| 28 | 
            +
            further details.
         | 
| 29 | 
            +
             | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'bundler'
         | 
| 3 | 
            +
            begin
         | 
| 4 | 
            +
              Bundler.setup(:default, :development)
         | 
| 5 | 
            +
            rescue Bundler::BundlerError => e
         | 
| 6 | 
            +
              $stderr.puts e.message
         | 
| 7 | 
            +
              $stderr.puts "Run `bundle install` to install missing gems"
         | 
| 8 | 
            +
              exit e.status_code
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
            require 'rake'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            require 'jeweler'
         | 
| 13 | 
            +
            Jeweler::Tasks.new do |gem|
         | 
| 14 | 
            +
              # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
         | 
| 15 | 
            +
              gem.name = "zferral"
         | 
| 16 | 
            +
              gem.homepage = "http://github.com/grasshopperlabs/zferral"
         | 
| 17 | 
            +
              gem.license = "MIT"
         | 
| 18 | 
            +
              gem.summary = %Q{A Ruby wrapper for the Zferral API}
         | 
| 19 | 
            +
              gem.description = %Q{A Ruby wrapper for the Zferral API, based on HTTParty.}
         | 
| 20 | 
            +
              gem.email = "michael@webadvocate.com"
         | 
| 21 | 
            +
              gem.authors = ["Michael Klett"]
         | 
| 22 | 
            +
              # Include your dependencies below. Runtime dependencies are required when using your gem,
         | 
| 23 | 
            +
              # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
         | 
| 24 | 
            +
              #  gem.add_runtime_dependency 'jabber4r', '> 0.1'
         | 
| 25 | 
            +
              #  gem.add_development_dependency 'rspec', '> 1.2.3'
         | 
| 26 | 
            +
            end
         | 
| 27 | 
            +
            Jeweler::RubygemsDotOrgTasks.new
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            require 'rspec/core'
         | 
| 30 | 
            +
            require 'rspec/core/rake_task'
         | 
| 31 | 
            +
            RSpec::Core::RakeTask.new(:spec) do |spec|
         | 
| 32 | 
            +
              spec.pattern = FileList['spec/**/*_spec.rb']
         | 
| 33 | 
            +
            end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            RSpec::Core::RakeTask.new(:rcov) do |spec|
         | 
| 36 | 
            +
              spec.pattern = 'spec/**/*_spec.rb'
         | 
| 37 | 
            +
              spec.rcov = true
         | 
| 38 | 
            +
            end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            task :default => :spec
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            require 'yard'
         | 
| 43 | 
            +
            YARD::Rake::YardocTask.new
         | 
    
        data/VERSION
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            0.2.0
         | 
    
        data/lib/zferral.rb
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            require "rubygems"
         | 
| 2 | 
            +
            require 'httparty'
         | 
| 3 | 
            +
            require 'json'
         | 
| 4 | 
            +
            require 'hashie'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Dir[File.join(File.dirname(__FILE__), 'zferral', '**', '*.rb')].each {|f| require f}
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module Zferral #:nodoc:
         | 
| 9 | 
            +
              # Creates a new API {Zferral::Client} with the passed arguments.
         | 
| 10 | 
            +
              #
         | 
| 11 | 
            +
              # This is the preferred entry point for the library.  In other words, create a client using
         | 
| 12 | 
            +
              # this method and access all of the API resources from here.
         | 
| 13 | 
            +
              #
         | 
| 14 | 
            +
              #   zferral = Zferral.new(:subdomain => 'sandbox', :api_token => 'c143c5450fb633c70c53b1bcc6348077')
         | 
| 15 | 
            +
              #   zferral.campaign.list
         | 
| 16 | 
            +
              #
         | 
| 17 | 
            +
              # @param (see Zferral::Client#initialize)
         | 
| 18 | 
            +
              # @return (see Zferral::Client#initialize)
         | 
| 19 | 
            +
              def self.new(*args)
         | 
| 20 | 
            +
                Zferral::Client.new(*args)
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            module Zferral
         | 
| 2 | 
            +
              # The Client holds the API credentials and orchestrates access to the Resources.
         | 
| 3 | 
            +
              class Client
         | 
| 4 | 
            +
                attr_accessor :subdomain
         | 
| 5 | 
            +
                attr_accessor :api_token
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                # @param [Hash] options API credentials, passed as a hash with 'subdomain' and 'api_token' keys
         | 
| 8 | 
            +
                def initialize(options = {})
         | 
| 9 | 
            +
                  self.subdomain = options[:subdomain] || options['subdomain']
         | 
| 10 | 
            +
                  self.api_token = options[:api_token] || options['api_token']
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
                
         | 
| 13 | 
            +
                # A {Zferral::Campaign} class connected to this Client
         | 
| 14 | 
            +
                #
         | 
| 15 | 
            +
                # @return [Zferral::Campaign]
         | 
| 16 | 
            +
                def campaign
         | 
| 17 | 
            +
                  Zferral::Campaign.connect(self)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
                
         | 
| 20 | 
            +
                # A {Zferral::Campaign} resource for this Client
         | 
| 21 | 
            +
                #
         | 
| 22 | 
            +
                # @return [Zferral::Campaign] {Zferral::Campaign} class
         | 
| 23 | 
            +
                def campaign
         | 
| 24 | 
            +
                  Zferral::Campaign.connect(self)
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
                
         | 
| 27 | 
            +
                # A {Zferral::Event} resource for this Client
         | 
| 28 | 
            +
                #
         | 
| 29 | 
            +
                # @return [Zferral::Event] {Zferral::Event} class
         | 
| 30 | 
            +
                def event
         | 
| 31 | 
            +
                  Zferral::Event.connect(self)
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            module Zferral
         | 
| 2 | 
            +
              # Raised when general resource errors are encountered.
         | 
| 3 | 
            +
              class ResourceError < StandardError
         | 
| 4 | 
            +
              end
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              # Raised when a fetch request for a particular ID results in no resource being found.
         | 
| 7 | 
            +
              class ResourceNotFound < StandardError
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
              
         | 
| 10 | 
            +
              # Raised when a particular Resource does not support the requested method
         | 
| 11 | 
            +
              class MethodNotSupported < StandardError
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,136 @@ | |
| 1 | 
            +
            module Zferral
         | 
| 2 | 
            +
              # The "base" resource from which all of the Zferral API resources subclass.  This class typically
         | 
| 3 | 
            +
              # isn't used directly; instead, you'll use the subclasses like {Zferral::Campaign}.
         | 
| 4 | 
            +
              class Resource < Hashie::Mash
         | 
| 5 | 
            +
                include HTTParty
         | 
| 6 | 
            +
                format :json
         | 
| 7 | 
            +
                headers 'Content-Type' => 'application/json', 'Accept' => 'application/json'
         | 
| 8 | 
            +
                debug_output $stdout
         | 
| 9 | 
            +
                
         | 
| 10 | 
            +
                # Used to "connect" the resource to a Client already configured with credentials.
         | 
| 11 | 
            +
                #
         | 
| 12 | 
            +
                # Upon connection, the passed in Client is stored (see .client), the base_uri
         | 
| 13 | 
            +
                # for HTTParty interaction is calculated, and the class is returned.
         | 
| 14 | 
            +
                #
         | 
| 15 | 
            +
                # @param [Client] client instance with credentials (subdomain and api_token attached)
         | 
| 16 | 
            +
                #
         | 
| 17 | 
            +
                # @return [Class]
         | 
| 18 | 
            +
                def self.connect(client)
         | 
| 19 | 
            +
                  @@client = client
         | 
| 20 | 
            +
                  self.base_uri("https://#{subdomain}.zferral.com/api/#{api_token}")
         | 
| 21 | 
            +
                  self
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
                
         | 
| 24 | 
            +
                # @return [String] The subdomain of the currently connected Client, or nil of no Client is connected.
         | 
| 25 | 
            +
                def self.subdomain
         | 
| 26 | 
            +
                  @@client.subdomain if @@client
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                # @return [String] The API token of the currently connected Client, or nil of no Client is connected.
         | 
| 30 | 
            +
                def self.api_token
         | 
| 31 | 
            +
                  @@client.api_token if @@client
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                # @return [String] The singular resource name (computed from the class name) to be used in resource URLs
         | 
| 35 | 
            +
                def self.resource_name
         | 
| 36 | 
            +
                  name.split("::").last.downcase
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
                
         | 
| 39 | 
            +
                # @return [String] The plural resource name (computed from the class name) to be used in resource URLs
         | 
| 40 | 
            +
                def self.resource_names
         | 
| 41 | 
            +
                  name.split("::").last.downcase + "s"
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
                
         | 
| 44 | 
            +
                # Get an array of all members of the resource list
         | 
| 45 | 
            +
                #
         | 
| 46 | 
            +
                # @return [Array] An array of the expected resource
         | 
| 47 | 
            +
                def self.list
         | 
| 48 | 
            +
                  handle_list get("/#{resource_names}.json")["#{resource_names}"]
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
                
         | 
| 51 | 
            +
                # Alias .all to .list
         | 
| 52 | 
            +
                class << self
         | 
| 53 | 
            +
                  alias_method :all, :list
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                # Fetches a single resource by ID
         | 
| 57 | 
            +
                #
         | 
| 58 | 
            +
                # @return [Resource] A single Resource object, or one of its subclasses
         | 
| 59 | 
            +
                #
         | 
| 60 | 
            +
                # @raise [ResourceError, ResourceNotFound]
         | 
| 61 | 
            +
                def self.fetch(id)
         | 
| 62 | 
            +
                  fetch_id(id)
         | 
| 63 | 
            +
                  handle_fetch get("/#{resource_name}/#{id}.json").parsed_response
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
                
         | 
| 66 | 
            +
                # {Resource.find} can be used with syntax like ActiveRecord to fetch lists or single resources.
         | 
| 67 | 
            +
                #
         | 
| 68 | 
            +
                # To fetch a list, use the +:all+ parameter:
         | 
| 69 | 
            +
                # 
         | 
| 70 | 
            +
                #   Resource.find(:all)
         | 
| 71 | 
            +
                #
         | 
| 72 | 
            +
                # To fetch a single Resource, pass an Integer ID
         | 
| 73 | 
            +
                #
         | 
| 74 | 
            +
                # @param [Symbol, Integer] +:all+ to fetch a list, an Integer to fetch a single Resource
         | 
| 75 | 
            +
                #
         | 
| 76 | 
            +
                # @return [Array, Resource] An Array of Resources or a single Resource
         | 
| 77 | 
            +
                #
         | 
| 78 | 
            +
                # @raise (see .fetch)
         | 
| 79 | 
            +
                def self.find(scope_or_id)
         | 
| 80 | 
            +
                  case scope_or_id
         | 
| 81 | 
            +
                  when Symbol
         | 
| 82 | 
            +
                    if scope_or_id == :all
         | 
| 83 | 
            +
                      list
         | 
| 84 | 
            +
                    end
         | 
| 85 | 
            +
                  when Integer, String
         | 
| 86 | 
            +
                    fetch(scope_or_id.to_i)
         | 
| 87 | 
            +
                  end
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
                
         | 
| 90 | 
            +
                private
         | 
| 91 | 
            +
                
         | 
| 92 | 
            +
                def self.client
         | 
| 93 | 
            +
                  @@client
         | 
| 94 | 
            +
                end
         | 
| 95 | 
            +
                
         | 
| 96 | 
            +
                def self.handle_list(list)
         | 
| 97 | 
            +
                  if list.is_a?(Array)
         | 
| 98 | 
            +
                    list.collect { |c| self.new(c) }
         | 
| 99 | 
            +
                  else
         | 
| 100 | 
            +
                    raise Zferral::ResourceError, "unexpected response while listing #{resource_names}: #{list.inspect[0..20]}"
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
                
         | 
| 104 | 
            +
                def self.fetch_id(id=nil)
         | 
| 105 | 
            +
                  @fetch_id = id unless id.nil?
         | 
| 106 | 
            +
                  @fetch_id
         | 
| 107 | 
            +
                end
         | 
| 108 | 
            +
                
         | 
| 109 | 
            +
                def self.handle_fetch(response)
         | 
| 110 | 
            +
                  case response
         | 
| 111 | 
            +
                  when Hash
         | 
| 112 | 
            +
                    case response.keys.first
         | 
| 113 | 
            +
                    when resource_name
         | 
| 114 | 
            +
                      resource = self.new(response[resource_name])
         | 
| 115 | 
            +
                      if resource.respond_to?(:error)
         | 
| 116 | 
            +
                        raise Zferral::ResourceError, resource.error
         | 
| 117 | 
            +
                      end
         | 
| 118 | 
            +
                      resource
         | 
| 119 | 
            +
                    when 'error'
         | 
| 120 | 
            +
                      code = response['error']['code']
         | 
| 121 | 
            +
                      case code
         | 
| 122 | 
            +
                      when '404'
         | 
| 123 | 
            +
                        raise Zferral::ResourceNotFound, "#{resource_name} with id=#{fetch_id} was not found"
         | 
| 124 | 
            +
                      else
         | 
| 125 | 
            +
                        raise Zferral::ResourceError, "#{resource_name} caused a #{code} error"
         | 
| 126 | 
            +
                      end
         | 
| 127 | 
            +
                    else
         | 
| 128 | 
            +
                      raise Zferral::ResourceError, "unexpected response: #{resource.inspect}" 
         | 
| 129 | 
            +
                    end
         | 
| 130 | 
            +
                  else
         | 
| 131 | 
            +
                    raise Zferral::ResourceError, "unexpected response: #{resource.inspect}"
         | 
| 132 | 
            +
                  end
         | 
| 133 | 
            +
                end
         | 
| 134 | 
            +
                  
         | 
| 135 | 
            +
              end
         | 
| 136 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            module Zferral
         | 
| 2 | 
            +
              # A Zferral Event Resource
         | 
| 3 | 
            +
              #
         | 
| 4 | 
            +
              # http://zferral.com/api-docs/event
         | 
| 5 | 
            +
              class Event < Resource
         | 
| 6 | 
            +
                # The event/call API method, used to register an event (i.e. sale)
         | 
| 7 | 
            +
                def self.call(params = {})
         | 
| 8 | 
            +
                  response = post("/event/call.json", :body => {:event => params}.to_json).parsed_response
         | 
| 9 | 
            +
                  handle_fetch response
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
                
         | 
| 12 | 
            +
                # A special invocation of the event/call API method, used to register recurring revenue events.
         | 
| 13 | 
            +
                #
         | 
| 14 | 
            +
                # These calls add the +ignore_cookie+ flag, so that an affiliate ID or cookie is not needed.
         | 
| 15 | 
            +
                # Instead, the affiliate to credit is identified by the +customer_id+ attribute, assuming that
         | 
| 16 | 
            +
                # the +customer_id+ has been associated with the Affiliate already via a normal .call method
         | 
| 17 | 
            +
                # or via the Zferral tracking code (img tag or javascript).
         | 
| 18 | 
            +
                def self.call_recurring(params = {})
         | 
| 19 | 
            +
                  params.merge!(:ignore_cookie => '1')
         | 
| 20 | 
            +
                  call(params)
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
                
         | 
| 23 | 
            +
                # Not supported by Event
         | 
| 24 | 
            +
                def self.list
         | 
| 25 | 
            +
                  raise MethodNotSupported, "Event does not support the .list method"
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                # Not supported by Event
         | 
| 29 | 
            +
                def self.fetch(id)
         | 
| 30 | 
            +
                  raise MethodNotSupported, "Event does not support the .fetch method"
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Zferral::Campaign do
         | 
| 4 | 
            +
              use_vcr_cassette "campaigns"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              let(:campaign) { Zferral.new(:subdomain => subdomain, :api_token => api_token).campaign }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              describe "#list" do
         | 
| 9 | 
            +
                it "returns an array of your campaigns" do
         | 
| 10 | 
            +
                  campaign.list.should be_an_array_of_campaigns
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
                
         | 
| 13 | 
            +
                it "is aliased by #all" do
         | 
| 14 | 
            +
                  campaign.all.should == campaign.list
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
                
         | 
| 17 | 
            +
                it "is aliased by #find(:all)" do
         | 
| 18 | 
            +
                  campaign.find(:all).should == campaign.list
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
              
         | 
| 22 | 
            +
              describe "#fetch" do
         | 
| 23 | 
            +
                context "given a valid ID" do
         | 
| 24 | 
            +
                  it "fetches and returns the campaign" do
         | 
| 25 | 
            +
                    campaign.fetch(1).should be_a_campaign
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
                context "given an invalid ID" do
         | 
| 29 | 
            +
                  it "raises a ResourceNotFound exception" do
         | 
| 30 | 
            +
                    lambda { campaign.fetch(9999999) }.should raise_error(Zferral::ResourceNotFound, "campaign with id=9999999 was not found")
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
                
         | 
| 34 | 
            +
                it "is aliased by #find(id)" do
         | 
| 35 | 
            +
                  campaign.find(1).should == campaign.fetch(1)
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
    
        data/spec/event_spec.rb
    ADDED
    
    | @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Zferral::Event do
         | 
| 4 | 
            +
              use_vcr_cassette "events", :match_requests_on => [:uri, :method, :body]
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              let(:event) { Zferral.new(:subdomain => subdomain, :api_token => api_token).event }
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              describe "#call" do
         | 
| 9 | 
            +
                context "passing all required params, with debug" do
         | 
| 10 | 
            +
                  it "returns an event containing the commission_sum" do
         | 
| 11 | 
            +
                    resource = event.call(:debug => '1', :campaign_id => 1, :revenue => 20.00, :customer_id => "1", :affiliate_id => 538)
         | 
| 12 | 
            +
                    resource.should respond_to(:commission_sum)
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
                
         | 
| 16 | 
            +
                context "with a missing campaign_id" do
         | 
| 17 | 
            +
                  it "raises a ResourceError with the error displayed" do
         | 
| 18 | 
            +
                    lambda {
         | 
| 19 | 
            +
                      event.call(:debug => '1', :revenue => 20.00, :customer_id => "1", :affiliate_id => 538)
         | 
| 20 | 
            +
                    }.should raise_error(Zferral::ResourceError, "Campaign ID is not set.")
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                context "with none of the required parameters" do
         | 
| 25 | 
            +
                  it "raises a ResourceError with the first encountered error displayed" do
         | 
| 26 | 
            +
                    lambda {
         | 
| 27 | 
            +
                      event.call(:debug => '1')
         | 
| 28 | 
            +
                    }.should raise_error(Zferral::ResourceError, "Campaign ID is not set.")
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
              
         | 
| 33 | 
            +
              describe "#call_recurring" do
         | 
| 34 | 
            +
                it "invokes call after merging the option to ignore the cookie" do
         | 
| 35 | 
            +
                  hash = {:debug => '1', :campaign_id => 1, :revenue => 20.00, :customer_id => "1", :affiliate_id => 538}
         | 
| 36 | 
            +
                  event.should_receive(:call).with(hash.merge(:ignore_cookie => '1'))
         | 
| 37 | 
            +
                  event.call_recurring(hash)
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
                
         | 
| 40 | 
            +
                it "posts the event successfully without passing an affiliate id if the customer_id is previously 'registered'" do
         | 
| 41 | 
            +
                  resource = event.call_recurring(:debug => '1', :campaign_id => 1, :revenue => 20.00, :customer_id => "1")
         | 
| 42 | 
            +
                  resource.should respond_to(:commission_sum)
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                it "posts the event unsuccessfully without passing an affiliate id if the customer_id is not previously 'registered'" do
         | 
| 46 | 
            +
                  lambda {
         | 
| 47 | 
            +
                    event.call_recurring(:debug => '1', :campaign_id => 1, :revenue => 20.00, :customer_id => "foobarjones")
         | 
| 48 | 
            +
                  }.should raise_error(Zferral::ResourceError, "Neither cookie found nor referer set.")
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         | 
| 2 | 
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         | 
| 3 | 
            +
            require 'rspec'
         | 
| 4 | 
            +
            require 'vcr'
         | 
| 5 | 
            +
            require 'webmock/rspec'
         | 
| 6 | 
            +
            require 'zferral'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            # Requires supporting files with custom matchers and macros, etc,
         | 
| 9 | 
            +
            # in ./support/ and its subdirectories.
         | 
| 10 | 
            +
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            RSpec.configure do |config|
         | 
| 13 | 
            +
              config.extend VCR::RSpec::Macros
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            VCR.config do |c|
         | 
| 17 | 
            +
              c.cassette_library_dir     = 'spec/vcr_cassettes'
         | 
| 18 | 
            +
              c.stub_with                :webmock
         | 
| 19 | 
            +
              c.default_cassette_options = { :record => :new_episodes }
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            def test_credentials
         | 
| 23 | 
            +
              @test_credentials ||= {'subdomain' => subdomain, 'api_token' => api_token}
         | 
| 24 | 
            +
            end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            def subdomain
         | 
| 27 | 
            +
              'sandbox'
         | 
| 28 | 
            +
            end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            def api_token
         | 
| 31 | 
            +
              'c143c5450fb633c70c53b1bcc6348077'
         | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
              
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            RSpec::Matchers.define :be_an_array_of_campaigns do
         | 
| 2 | 
            +
              match do |actual|
         | 
| 3 | 
            +
                actual.is_a?(Array) && actual.first.is_a?(Hashie::Mash) && actual.first.respond_to?(:campaign_status_id)
         | 
| 4 | 
            +
              end
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              failure_message_for_should do |actual|
         | 
| 7 | 
            +
                "expected an array of Campaigns, got #{actual.inspect}"
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              failure_message_for_should_not do |actual|
         | 
| 11 | 
            +
                "expected to not receive an array of Campaigns, got #{actual.inspect}"
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            RSpec::Matchers.define :be_a_campaign do
         | 
| 16 | 
            +
              match do |actual|
         | 
| 17 | 
            +
                actual.is_a?(Hashie::Mash) && actual.respond_to?(:campaign_status_id)
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              
         | 
| 20 | 
            +
              failure_message_for_should do |actual|
         | 
| 21 | 
            +
                "expected a Campaign, got #{actual.inspect}"
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              failure_message_for_should_not do |actual|
         | 
| 25 | 
            +
                "expected not a Campaign, got #{actual.inspect}"
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
             | 
| @@ -0,0 +1,119 @@ | |
| 1 | 
            +
            --- 
         | 
| 2 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 3 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 4 | 
            +
                method: :get
         | 
| 5 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/campaigns.json
         | 
| 6 | 
            +
                body: 
         | 
| 7 | 
            +
                headers: 
         | 
| 8 | 
            +
                  accept: 
         | 
| 9 | 
            +
                  - application/json
         | 
| 10 | 
            +
                  content-type: 
         | 
| 11 | 
            +
                  - application/json
         | 
| 12 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 13 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 14 | 
            +
                  code: 200
         | 
| 15 | 
            +
                  message: OK
         | 
| 16 | 
            +
                headers: 
         | 
| 17 | 
            +
                  x-powered-by: 
         | 
| 18 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 19 | 
            +
                  content-type: 
         | 
| 20 | 
            +
                  - application/json; charset=utf-8
         | 
| 21 | 
            +
                  server: 
         | 
| 22 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 23 | 
            +
                  date: 
         | 
| 24 | 
            +
                  - Thu, 27 Jan 2011 19:11:17 GMT
         | 
| 25 | 
            +
                  content-length: 
         | 
| 26 | 
            +
                  - "847"
         | 
| 27 | 
            +
                  set-cookie: 
         | 
| 28 | 
            +
                  - zferral=34cb69dbc3ea8dcee785cda0cc18e31e; path=/
         | 
| 29 | 
            +
                body: "{\"campaigns\":[{\"id\":1,\"commission_type_id\":2,\"campaign_status_id\":1,\"event_id\":2,\"reward_points_type_id\":null,\"is_monetary\":true,\"is_private\":false,\"name\":\"Sample Revenue Share\",\"date_start\":\"2010-08-25\",\"date_end\":\"9999-12-01\",\"has_tiered_commission\":false,\"has_stepped_commission\":false,\"initial_commission\":\"10.00\",\"recurring_commission\":null,\"has_recurring_limited_by_renewals\":false,\"renewals_number\":null,\"has_recurring_limited_by_period\":false,\"recurring_end_date\":null,\"recurring_period_in_days\":null,\"has_simple_recurring_commissions\":false,\"has_auto_approval_commission\":true,\"commission_approved_callback_url\":null,\"description\":\"Refer a new customer, receive 10% of the revenue generated, for life.\",\"cookie_expire\":\"2010-11-25 00:00:00\",\"created_at\":\"2010-08-25 12:49:06\",\"landing_page_url\":\"http:\\/\\/zferral.com\",\"deleted_at\":null}]}"
         | 
| 30 | 
            +
                http_version: "1.1"
         | 
| 31 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 32 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 33 | 
            +
                method: :get
         | 
| 34 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/campaign/1.json
         | 
| 35 | 
            +
                body: 
         | 
| 36 | 
            +
                headers: 
         | 
| 37 | 
            +
                  accept: 
         | 
| 38 | 
            +
                  - application/json
         | 
| 39 | 
            +
                  content-type: 
         | 
| 40 | 
            +
                  - application/json
         | 
| 41 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 42 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 43 | 
            +
                  code: 200
         | 
| 44 | 
            +
                  message: OK
         | 
| 45 | 
            +
                headers: 
         | 
| 46 | 
            +
                  x-powered-by: 
         | 
| 47 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 48 | 
            +
                  content-type: 
         | 
| 49 | 
            +
                  - application/json; charset=utf-8
         | 
| 50 | 
            +
                  date: 
         | 
| 51 | 
            +
                  - Thu, 27 Jan 2011 19:11:18 GMT
         | 
| 52 | 
            +
                  server: 
         | 
| 53 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 54 | 
            +
                  content-length: 
         | 
| 55 | 
            +
                  - "844"
         | 
| 56 | 
            +
                  set-cookie: 
         | 
| 57 | 
            +
                  - zferral=58c023f43ec7907beca9357e31b7ea5f; path=/
         | 
| 58 | 
            +
                body: "{\"campaign\":{\"id\":1,\"commission_type_id\":2,\"campaign_status_id\":1,\"event_id\":2,\"reward_points_type_id\":null,\"is_monetary\":true,\"is_private\":false,\"name\":\"Sample Revenue Share\",\"date_start\":\"2010-08-25\",\"date_end\":\"9999-12-01\",\"has_tiered_commission\":false,\"has_stepped_commission\":false,\"initial_commission\":\"10.00\",\"recurring_commission\":null,\"has_recurring_limited_by_renewals\":false,\"renewals_number\":null,\"has_recurring_limited_by_period\":false,\"recurring_end_date\":null,\"recurring_period_in_days\":null,\"has_simple_recurring_commissions\":false,\"has_auto_approval_commission\":true,\"commission_approved_callback_url\":null,\"description\":\"Refer a new customer, receive 10% of the revenue generated, for life.\",\"cookie_expire\":\"2010-11-25 00:00:00\",\"created_at\":\"2010-08-25 12:49:06\",\"landing_page_url\":\"http:\\/\\/zferral.com\",\"deleted_at\":null}}"
         | 
| 59 | 
            +
                http_version: "1.1"
         | 
| 60 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 61 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 62 | 
            +
                method: :get
         | 
| 63 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/campaign/1.json
         | 
| 64 | 
            +
                body: 
         | 
| 65 | 
            +
                headers: 
         | 
| 66 | 
            +
                  accept: 
         | 
| 67 | 
            +
                  - application/json
         | 
| 68 | 
            +
                  content-type: 
         | 
| 69 | 
            +
                  - application/json
         | 
| 70 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 71 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 72 | 
            +
                  code: 200
         | 
| 73 | 
            +
                  message: OK
         | 
| 74 | 
            +
                headers: 
         | 
| 75 | 
            +
                  x-powered-by: 
         | 
| 76 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 77 | 
            +
                  content-type: 
         | 
| 78 | 
            +
                  - application/json; charset=utf-8
         | 
| 79 | 
            +
                  date: 
         | 
| 80 | 
            +
                  - Thu, 27 Jan 2011 19:11:18 GMT
         | 
| 81 | 
            +
                  server: 
         | 
| 82 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 83 | 
            +
                  content-length: 
         | 
| 84 | 
            +
                  - "844"
         | 
| 85 | 
            +
                  set-cookie: 
         | 
| 86 | 
            +
                  - zferral=eca13fe9ab58c58ac2298a5bfbe56ce4; path=/
         | 
| 87 | 
            +
                body: "{\"campaign\":{\"id\":1,\"commission_type_id\":2,\"campaign_status_id\":1,\"event_id\":2,\"reward_points_type_id\":null,\"is_monetary\":true,\"is_private\":false,\"name\":\"Sample Revenue Share\",\"date_start\":\"2010-08-25\",\"date_end\":\"9999-12-01\",\"has_tiered_commission\":false,\"has_stepped_commission\":false,\"initial_commission\":\"10.00\",\"recurring_commission\":null,\"has_recurring_limited_by_renewals\":false,\"renewals_number\":null,\"has_recurring_limited_by_period\":false,\"recurring_end_date\":null,\"recurring_period_in_days\":null,\"has_simple_recurring_commissions\":false,\"has_auto_approval_commission\":true,\"commission_approved_callback_url\":null,\"description\":\"Refer a new customer, receive 10% of the revenue generated, for life.\",\"cookie_expire\":\"2010-11-25 00:00:00\",\"created_at\":\"2010-08-25 12:49:06\",\"landing_page_url\":\"http:\\/\\/zferral.com\",\"deleted_at\":null}}"
         | 
| 88 | 
            +
                http_version: "1.1"
         | 
| 89 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 90 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 91 | 
            +
                method: :get
         | 
| 92 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/campaign/9999999.json
         | 
| 93 | 
            +
                body: 
         | 
| 94 | 
            +
                headers: 
         | 
| 95 | 
            +
                  accept: 
         | 
| 96 | 
            +
                  - application/json
         | 
| 97 | 
            +
                  content-type: 
         | 
| 98 | 
            +
                  - application/json
         | 
| 99 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 100 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 101 | 
            +
                  code: 404
         | 
| 102 | 
            +
                  message: Not Found
         | 
| 103 | 
            +
                headers: 
         | 
| 104 | 
            +
                  x-powered-by: 
         | 
| 105 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 106 | 
            +
                  content-type: 
         | 
| 107 | 
            +
                  - application/json; charset=utf-8
         | 
| 108 | 
            +
                  server: 
         | 
| 109 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 110 | 
            +
                  date: 
         | 
| 111 | 
            +
                  - Thu, 27 Jan 2011 19:11:19 GMT
         | 
| 112 | 
            +
                  content-length: 
         | 
| 113 | 
            +
                  - "46"
         | 
| 114 | 
            +
                  set-cookie: 
         | 
| 115 | 
            +
                  - zferral=3c862251ddc530dd6eada7f3e1d493a4; path=/
         | 
| 116 | 
            +
                  status: 
         | 
| 117 | 
            +
                  - 404 Not Found
         | 
| 118 | 
            +
                body: "{\"error\":{\"code\":\"404\",\"message\":\"Not Found\"}}"
         | 
| 119 | 
            +
                http_version: "1.1"
         | 
| @@ -0,0 +1,207 @@ | |
| 1 | 
            +
            --- 
         | 
| 2 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 3 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 4 | 
            +
                method: :post
         | 
| 5 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/event/call.json
         | 
| 6 | 
            +
                body: "{\"event\":{\"debug\":\"1\",\"campaign_id\":1,\"revenue\":20.0,\"customer_id\":\"1\",\"affiliate_id\":538}}"
         | 
| 7 | 
            +
                headers: 
         | 
| 8 | 
            +
                  accept: 
         | 
| 9 | 
            +
                  - application/json
         | 
| 10 | 
            +
                  content-type: 
         | 
| 11 | 
            +
                  - application/json
         | 
| 12 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 13 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 14 | 
            +
                  code: 200
         | 
| 15 | 
            +
                  message: OK
         | 
| 16 | 
            +
                headers: 
         | 
| 17 | 
            +
                  x-powered-by: 
         | 
| 18 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 19 | 
            +
                  content-type: 
         | 
| 20 | 
            +
                  - application/json; charset=utf-8
         | 
| 21 | 
            +
                  server: 
         | 
| 22 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 23 | 
            +
                  date: 
         | 
| 24 | 
            +
                  - Thu, 27 Jan 2011 19:11:21 GMT
         | 
| 25 | 
            +
                  content-length: 
         | 
| 26 | 
            +
                  - "30"
         | 
| 27 | 
            +
                  set-cookie: 
         | 
| 28 | 
            +
                  - cuid=8295b918f98f70f8d09511d9044ea543; expires=Wed, 01-Jan-2020 05:00:00 GMT; path=/; domain=sandbox.zferral.com
         | 
| 29 | 
            +
                  - zferral=8a0518ef003e7f83628a6c8d61b193c6; path=/
         | 
| 30 | 
            +
                body: "{\"event\":{\"commission_sum\":2}}"
         | 
| 31 | 
            +
                http_version: "1.1"
         | 
| 32 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 33 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 34 | 
            +
                method: :post
         | 
| 35 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/event/call.json
         | 
| 36 | 
            +
                body: "{\"event\":{\"debug\":\"1\",\"revenue\":20.0,\"customer_id\":\"1\",\"affiliate_id\":538}}"
         | 
| 37 | 
            +
                headers: 
         | 
| 38 | 
            +
                  accept: 
         | 
| 39 | 
            +
                  - application/json
         | 
| 40 | 
            +
                  content-type: 
         | 
| 41 | 
            +
                  - application/json
         | 
| 42 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 43 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 44 | 
            +
                  code: 200
         | 
| 45 | 
            +
                  message: OK
         | 
| 46 | 
            +
                headers: 
         | 
| 47 | 
            +
                  x-powered-by: 
         | 
| 48 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 49 | 
            +
                  content-type: 
         | 
| 50 | 
            +
                  - application/json; charset=utf-8
         | 
| 51 | 
            +
                  date: 
         | 
| 52 | 
            +
                  - Thu, 27 Jan 2011 19:11:22 GMT
         | 
| 53 | 
            +
                  server: 
         | 
| 54 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 55 | 
            +
                  content-length: 
         | 
| 56 | 
            +
                  - "45"
         | 
| 57 | 
            +
                  set-cookie: 
         | 
| 58 | 
            +
                  - zferral=ff098b069200835b71e4c38c5d203ef6; path=/
         | 
| 59 | 
            +
                body: "{\"event\":{\"error\":\"Campaign ID is not set.\"}}"
         | 
| 60 | 
            +
                http_version: "1.1"
         | 
| 61 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 62 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 63 | 
            +
                method: :post
         | 
| 64 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/event/call.json
         | 
| 65 | 
            +
                body: "{\"event\":{\"debug\":\"1\"}}"
         | 
| 66 | 
            +
                headers: 
         | 
| 67 | 
            +
                  accept: 
         | 
| 68 | 
            +
                  - application/json
         | 
| 69 | 
            +
                  content-type: 
         | 
| 70 | 
            +
                  - application/json
         | 
| 71 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 72 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 73 | 
            +
                  code: 200
         | 
| 74 | 
            +
                  message: OK
         | 
| 75 | 
            +
                headers: 
         | 
| 76 | 
            +
                  x-powered-by: 
         | 
| 77 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 78 | 
            +
                  content-type: 
         | 
| 79 | 
            +
                  - application/json; charset=utf-8
         | 
| 80 | 
            +
                  server: 
         | 
| 81 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 82 | 
            +
                  date: 
         | 
| 83 | 
            +
                  - Thu, 27 Jan 2011 19:11:23 GMT
         | 
| 84 | 
            +
                  content-length: 
         | 
| 85 | 
            +
                  - "45"
         | 
| 86 | 
            +
                  set-cookie: 
         | 
| 87 | 
            +
                  - zferral=e1f89862984eebf98420674e6c5dab82; path=/
         | 
| 88 | 
            +
                body: "{\"event\":{\"error\":\"Campaign ID is not set.\"}}"
         | 
| 89 | 
            +
                http_version: "1.1"
         | 
| 90 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 91 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 92 | 
            +
                method: :post
         | 
| 93 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/event/call.json
         | 
| 94 | 
            +
                body: "{\"event\":{\"debug\":\"1\",\"campaign_id\":1,\"ignore_cookie\":\"1\",\"revenue\":20.0,\"customer_id\":\"1\"}}"
         | 
| 95 | 
            +
                headers: 
         | 
| 96 | 
            +
                  accept: 
         | 
| 97 | 
            +
                  - application/json
         | 
| 98 | 
            +
                  content-type: 
         | 
| 99 | 
            +
                  - application/json
         | 
| 100 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 101 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 102 | 
            +
                  code: 200
         | 
| 103 | 
            +
                  message: OK
         | 
| 104 | 
            +
                headers: 
         | 
| 105 | 
            +
                  x-powered-by: 
         | 
| 106 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 107 | 
            +
                  content-type: 
         | 
| 108 | 
            +
                  - application/json; charset=utf-8
         | 
| 109 | 
            +
                  date: 
         | 
| 110 | 
            +
                  - Thu, 27 Jan 2011 19:11:24 GMT
         | 
| 111 | 
            +
                  server: 
         | 
| 112 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 113 | 
            +
                  content-length: 
         | 
| 114 | 
            +
                  - "30"
         | 
| 115 | 
            +
                  set-cookie: 
         | 
| 116 | 
            +
                  - cuid=8295b918f98f70f8d09511d9044ea543; expires=Wed, 01-Jan-2020 05:00:00 GMT; path=/; domain=sandbox.zferral.com
         | 
| 117 | 
            +
                  - zferral=239337692a5ea21deb195c8be0a6c1cf; path=/
         | 
| 118 | 
            +
                body: "{\"event\":{\"commission_sum\":2}}"
         | 
| 119 | 
            +
                http_version: "1.1"
         | 
| 120 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 121 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 122 | 
            +
                method: :post
         | 
| 123 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/event/call.json
         | 
| 124 | 
            +
                body: "{\"event\":{\"debug\":\"1\",\"campaign_id\":1,\"ignore_cookie\":\"1\",\"revenue\":20.0,\"customer_id\":\"foobarjones\"}}"
         | 
| 125 | 
            +
                headers: 
         | 
| 126 | 
            +
                  accept: 
         | 
| 127 | 
            +
                  - application/json
         | 
| 128 | 
            +
                  content-type: 
         | 
| 129 | 
            +
                  - application/json
         | 
| 130 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 131 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 132 | 
            +
                  code: 200
         | 
| 133 | 
            +
                  message: OK
         | 
| 134 | 
            +
                headers: 
         | 
| 135 | 
            +
                  x-powered-by: 
         | 
| 136 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 137 | 
            +
                  content-type: 
         | 
| 138 | 
            +
                  - application/json; charset=utf-8
         | 
| 139 | 
            +
                  server: 
         | 
| 140 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 141 | 
            +
                  date: 
         | 
| 142 | 
            +
                  - Thu, 27 Jan 2011 19:11:25 GMT
         | 
| 143 | 
            +
                  content-length: 
         | 
| 144 | 
            +
                  - "59"
         | 
| 145 | 
            +
                  set-cookie: 
         | 
| 146 | 
            +
                  - zferral=aea87a857d0d423d913c442d74935ede; path=/
         | 
| 147 | 
            +
                body: "{\"event\":{\"error\":\"Neither cookie found nor referer set.\"}}"
         | 
| 148 | 
            +
                http_version: "1.1"
         | 
| 149 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 150 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 151 | 
            +
                method: :post
         | 
| 152 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/event/call.json
         | 
| 153 | 
            +
                body: "{\"event\":{\"affiliate_id\":538,\"debug\":\"1\",\"campaign_id\":1,\"revenue\":20.0,\"customer_id\":\"1\"}}"
         | 
| 154 | 
            +
                headers: 
         | 
| 155 | 
            +
                  accept: 
         | 
| 156 | 
            +
                  - application/json
         | 
| 157 | 
            +
                  content-type: 
         | 
| 158 | 
            +
                  - application/json
         | 
| 159 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 160 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 161 | 
            +
                  code: 200
         | 
| 162 | 
            +
                  message: OK
         | 
| 163 | 
            +
                headers: 
         | 
| 164 | 
            +
                  x-powered-by: 
         | 
| 165 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 166 | 
            +
                  content-type: 
         | 
| 167 | 
            +
                  - application/json; charset=utf-8
         | 
| 168 | 
            +
                  date: 
         | 
| 169 | 
            +
                  - Thu, 27 Jan 2011 19:47:20 GMT
         | 
| 170 | 
            +
                  server: 
         | 
| 171 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 172 | 
            +
                  content-length: 
         | 
| 173 | 
            +
                  - "30"
         | 
| 174 | 
            +
                  set-cookie: 
         | 
| 175 | 
            +
                  - cuid=8295b918f98f70f8d09511d9044ea543; expires=Wed, 01-Jan-2020 05:00:00 GMT; path=/; domain=sandbox.zferral.com
         | 
| 176 | 
            +
                  - zferral=5567f5f61c1d97bae1435e22f80e8d3a; path=/
         | 
| 177 | 
            +
                body: "{\"event\":{\"commission_sum\":2}}"
         | 
| 178 | 
            +
                http_version: "1.1"
         | 
| 179 | 
            +
            - !ruby/struct:VCR::HTTPInteraction 
         | 
| 180 | 
            +
              request: !ruby/struct:VCR::Request 
         | 
| 181 | 
            +
                method: :post
         | 
| 182 | 
            +
                uri: https://sandbox.zferral.com:443/api/c143c5450fb633c70c53b1bcc6348077/event/call.json
         | 
| 183 | 
            +
                body: "{\"event\":{\"affiliate_id\":538,\"debug\":\"1\",\"revenue\":20.0,\"customer_id\":\"1\"}}"
         | 
| 184 | 
            +
                headers: 
         | 
| 185 | 
            +
                  accept: 
         | 
| 186 | 
            +
                  - application/json
         | 
| 187 | 
            +
                  content-type: 
         | 
| 188 | 
            +
                  - application/json
         | 
| 189 | 
            +
              response: !ruby/struct:VCR::Response 
         | 
| 190 | 
            +
                status: !ruby/struct:VCR::ResponseStatus 
         | 
| 191 | 
            +
                  code: 200
         | 
| 192 | 
            +
                  message: OK
         | 
| 193 | 
            +
                headers: 
         | 
| 194 | 
            +
                  x-powered-by: 
         | 
| 195 | 
            +
                  - PHP/5.2.17-0.dotdeb.0
         | 
| 196 | 
            +
                  content-type: 
         | 
| 197 | 
            +
                  - application/json; charset=utf-8
         | 
| 198 | 
            +
                  server: 
         | 
| 199 | 
            +
                  - Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
         | 
| 200 | 
            +
                  date: 
         | 
| 201 | 
            +
                  - Thu, 27 Jan 2011 19:47:21 GMT
         | 
| 202 | 
            +
                  content-length: 
         | 
| 203 | 
            +
                  - "45"
         | 
| 204 | 
            +
                  set-cookie: 
         | 
| 205 | 
            +
                  - zferral=9a1d9025277bff7468e148f7b8d673e6; path=/
         | 
| 206 | 
            +
                body: "{\"event\":{\"error\":\"Campaign ID is not set.\"}}"
         | 
| 207 | 
            +
                http_version: "1.1"
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe "Zferral" do
         | 
| 4 | 
            +
              describe ".new" do
         | 
| 5 | 
            +
                it "creates a new instance of Zferral::Client" do
         | 
| 6 | 
            +
                  Zferral.new.should be_a(Zferral::Client)
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
              
         | 
| 10 | 
            +
              describe "#campaign" do
         | 
| 11 | 
            +
                it "provides access to the Campaign class with a linkage to the client" do
         | 
| 12 | 
            +
                  zferral = Zferral.new(:subdomain => subdomain, :api_token => api_token)
         | 
| 13 | 
            +
                  zferral.campaign.should == Zferral::Campaign
         | 
| 14 | 
            +
                  zferral.campaign.client.should == zferral
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              describe "#event" do
         | 
| 19 | 
            +
                it "provides access to the Event class with a linkage to the client" do
         | 
| 20 | 
            +
                  zferral = Zferral.new(:subdomain => subdomain, :api_token => api_token)
         | 
| 21 | 
            +
                  zferral.event.should == Zferral::Event
         | 
| 22 | 
            +
                  zferral.event.client.should == zferral
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
             | 
    
        data/zferral.gemspec
    ADDED
    
    | @@ -0,0 +1,96 @@ | |
| 1 | 
            +
            # Generated by jeweler
         | 
| 2 | 
            +
            # DO NOT EDIT THIS FILE DIRECTLY
         | 
| 3 | 
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         | 
| 4 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |s|
         | 
| 7 | 
            +
              s.name = %q{zferral}
         | 
| 8 | 
            +
              s.version = "0.2.0"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 | 
            +
              s.authors = ["Michael Klett"]
         | 
| 12 | 
            +
              s.date = %q{2011-01-27}
         | 
| 13 | 
            +
              s.description = %q{A Ruby wrapper for the Zferral API, based on HTTParty.}
         | 
| 14 | 
            +
              s.email = %q{michael@webadvocate.com}
         | 
| 15 | 
            +
              s.extra_rdoc_files = [
         | 
| 16 | 
            +
                "LICENSE.txt",
         | 
| 17 | 
            +
                "README.rdoc"
         | 
| 18 | 
            +
              ]
         | 
| 19 | 
            +
              s.files = [
         | 
| 20 | 
            +
                ".document",
         | 
| 21 | 
            +
                ".rspec",
         | 
| 22 | 
            +
                "Gemfile",
         | 
| 23 | 
            +
                "Gemfile.lock",
         | 
| 24 | 
            +
                "LICENSE.txt",
         | 
| 25 | 
            +
                "README.rdoc",
         | 
| 26 | 
            +
                "Rakefile",
         | 
| 27 | 
            +
                "VERSION",
         | 
| 28 | 
            +
                "lib/zferral.rb",
         | 
| 29 | 
            +
                "lib/zferral/client.rb",
         | 
| 30 | 
            +
                "lib/zferral/errors.rb",
         | 
| 31 | 
            +
                "lib/zferral/resource.rb",
         | 
| 32 | 
            +
                "lib/zferral/resources/campaign.rb",
         | 
| 33 | 
            +
                "lib/zferral/resources/event.rb",
         | 
| 34 | 
            +
                "spec/campaign_spec.rb",
         | 
| 35 | 
            +
                "spec/event_spec.rb",
         | 
| 36 | 
            +
                "spec/spec_helper.rb",
         | 
| 37 | 
            +
                "spec/support/matchers/be.rb",
         | 
| 38 | 
            +
                "spec/vcr_cassettes/campaigns.yml",
         | 
| 39 | 
            +
                "spec/vcr_cassettes/events.yml",
         | 
| 40 | 
            +
                "spec/zferral_spec.rb",
         | 
| 41 | 
            +
                "zferral.gemspec"
         | 
| 42 | 
            +
              ]
         | 
| 43 | 
            +
              s.homepage = %q{http://github.com/grasshopperlabs/zferral}
         | 
| 44 | 
            +
              s.licenses = ["MIT"]
         | 
| 45 | 
            +
              s.require_paths = ["lib"]
         | 
| 46 | 
            +
              s.rubygems_version = %q{1.3.7}
         | 
| 47 | 
            +
              s.summary = %q{A Ruby wrapper for the Zferral API}
         | 
| 48 | 
            +
              s.test_files = [
         | 
| 49 | 
            +
                "spec/campaign_spec.rb",
         | 
| 50 | 
            +
                "spec/event_spec.rb",
         | 
| 51 | 
            +
                "spec/spec_helper.rb",
         | 
| 52 | 
            +
                "spec/support/matchers/be.rb",
         | 
| 53 | 
            +
                "spec/zferral_spec.rb"
         | 
| 54 | 
            +
              ]
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              if s.respond_to? :specification_version then
         | 
| 57 | 
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 58 | 
            +
                s.specification_version = 3
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
| 61 | 
            +
                  s.add_runtime_dependency(%q<httparty>, [">= 0"])
         | 
| 62 | 
            +
                  s.add_runtime_dependency(%q<json>, [">= 0"])
         | 
| 63 | 
            +
                  s.add_runtime_dependency(%q<hashie>, [">= 0"])
         | 
| 64 | 
            +
                  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
         | 
| 65 | 
            +
                  s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
         | 
| 66 | 
            +
                  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 67 | 
            +
                  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
         | 
| 68 | 
            +
                  s.add_development_dependency(%q<rcov>, [">= 0"])
         | 
| 69 | 
            +
                  s.add_development_dependency(%q<vcr>, [">= 0"])
         | 
| 70 | 
            +
                  s.add_development_dependency(%q<webmock>, [">= 0"])
         | 
| 71 | 
            +
                else
         | 
| 72 | 
            +
                  s.add_dependency(%q<httparty>, [">= 0"])
         | 
| 73 | 
            +
                  s.add_dependency(%q<json>, [">= 0"])
         | 
| 74 | 
            +
                  s.add_dependency(%q<hashie>, [">= 0"])
         | 
| 75 | 
            +
                  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
         | 
| 76 | 
            +
                  s.add_dependency(%q<yard>, ["~> 0.6.0"])
         | 
| 77 | 
            +
                  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 78 | 
            +
                  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
         | 
| 79 | 
            +
                  s.add_dependency(%q<rcov>, [">= 0"])
         | 
| 80 | 
            +
                  s.add_dependency(%q<vcr>, [">= 0"])
         | 
| 81 | 
            +
                  s.add_dependency(%q<webmock>, [">= 0"])
         | 
| 82 | 
            +
                end
         | 
| 83 | 
            +
              else
         | 
| 84 | 
            +
                s.add_dependency(%q<httparty>, [">= 0"])
         | 
| 85 | 
            +
                s.add_dependency(%q<json>, [">= 0"])
         | 
| 86 | 
            +
                s.add_dependency(%q<hashie>, [">= 0"])
         | 
| 87 | 
            +
                s.add_dependency(%q<rspec>, ["~> 2.3.0"])
         | 
| 88 | 
            +
                s.add_dependency(%q<yard>, ["~> 0.6.0"])
         | 
| 89 | 
            +
                s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 90 | 
            +
                s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
         | 
| 91 | 
            +
                s.add_dependency(%q<rcov>, [">= 0"])
         | 
| 92 | 
            +
                s.add_dependency(%q<vcr>, [">= 0"])
         | 
| 93 | 
            +
                s.add_dependency(%q<webmock>, [">= 0"])
         | 
| 94 | 
            +
              end
         | 
| 95 | 
            +
            end
         | 
| 96 | 
            +
             | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,240 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: zferral
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              hash: 23
         | 
| 5 | 
            +
              prerelease: false
         | 
| 6 | 
            +
              segments: 
         | 
| 7 | 
            +
              - 0
         | 
| 8 | 
            +
              - 2
         | 
| 9 | 
            +
              - 0
         | 
| 10 | 
            +
              version: 0.2.0
         | 
| 11 | 
            +
            platform: ruby
         | 
| 12 | 
            +
            authors: 
         | 
| 13 | 
            +
            - Michael Klett
         | 
| 14 | 
            +
            autorequire: 
         | 
| 15 | 
            +
            bindir: bin
         | 
| 16 | 
            +
            cert_chain: []
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            date: 2011-01-27 00:00:00 -05:00
         | 
| 19 | 
            +
            default_executable: 
         | 
| 20 | 
            +
            dependencies: 
         | 
| 21 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 22 | 
            +
              prerelease: false
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              name: httparty
         | 
| 25 | 
            +
              version_requirements: &id001 !ruby/object:Gem::Requirement 
         | 
| 26 | 
            +
                none: false
         | 
| 27 | 
            +
                requirements: 
         | 
| 28 | 
            +
                - - ">="
         | 
| 29 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 30 | 
            +
                    hash: 3
         | 
| 31 | 
            +
                    segments: 
         | 
| 32 | 
            +
                    - 0
         | 
| 33 | 
            +
                    version: "0"
         | 
| 34 | 
            +
              requirement: *id001
         | 
| 35 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 36 | 
            +
              prerelease: false
         | 
| 37 | 
            +
              type: :runtime
         | 
| 38 | 
            +
              name: json
         | 
| 39 | 
            +
              version_requirements: &id002 !ruby/object:Gem::Requirement 
         | 
| 40 | 
            +
                none: false
         | 
| 41 | 
            +
                requirements: 
         | 
| 42 | 
            +
                - - ">="
         | 
| 43 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 44 | 
            +
                    hash: 3
         | 
| 45 | 
            +
                    segments: 
         | 
| 46 | 
            +
                    - 0
         | 
| 47 | 
            +
                    version: "0"
         | 
| 48 | 
            +
              requirement: *id002
         | 
| 49 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 50 | 
            +
              prerelease: false
         | 
| 51 | 
            +
              type: :runtime
         | 
| 52 | 
            +
              name: hashie
         | 
| 53 | 
            +
              version_requirements: &id003 !ruby/object:Gem::Requirement 
         | 
| 54 | 
            +
                none: false
         | 
| 55 | 
            +
                requirements: 
         | 
| 56 | 
            +
                - - ">="
         | 
| 57 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 58 | 
            +
                    hash: 3
         | 
| 59 | 
            +
                    segments: 
         | 
| 60 | 
            +
                    - 0
         | 
| 61 | 
            +
                    version: "0"
         | 
| 62 | 
            +
              requirement: *id003
         | 
| 63 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 64 | 
            +
              prerelease: false
         | 
| 65 | 
            +
              type: :development
         | 
| 66 | 
            +
              name: rspec
         | 
| 67 | 
            +
              version_requirements: &id004 !ruby/object:Gem::Requirement 
         | 
| 68 | 
            +
                none: false
         | 
| 69 | 
            +
                requirements: 
         | 
| 70 | 
            +
                - - ~>
         | 
| 71 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 72 | 
            +
                    hash: 3
         | 
| 73 | 
            +
                    segments: 
         | 
| 74 | 
            +
                    - 2
         | 
| 75 | 
            +
                    - 3
         | 
| 76 | 
            +
                    - 0
         | 
| 77 | 
            +
                    version: 2.3.0
         | 
| 78 | 
            +
              requirement: *id004
         | 
| 79 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 80 | 
            +
              prerelease: false
         | 
| 81 | 
            +
              type: :development
         | 
| 82 | 
            +
              name: yard
         | 
| 83 | 
            +
              version_requirements: &id005 !ruby/object:Gem::Requirement 
         | 
| 84 | 
            +
                none: false
         | 
| 85 | 
            +
                requirements: 
         | 
| 86 | 
            +
                - - ~>
         | 
| 87 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 88 | 
            +
                    hash: 7
         | 
| 89 | 
            +
                    segments: 
         | 
| 90 | 
            +
                    - 0
         | 
| 91 | 
            +
                    - 6
         | 
| 92 | 
            +
                    - 0
         | 
| 93 | 
            +
                    version: 0.6.0
         | 
| 94 | 
            +
              requirement: *id005
         | 
| 95 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 96 | 
            +
              prerelease: false
         | 
| 97 | 
            +
              type: :development
         | 
| 98 | 
            +
              name: bundler
         | 
| 99 | 
            +
              version_requirements: &id006 !ruby/object:Gem::Requirement 
         | 
| 100 | 
            +
                none: false
         | 
| 101 | 
            +
                requirements: 
         | 
| 102 | 
            +
                - - ~>
         | 
| 103 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 104 | 
            +
                    hash: 23
         | 
| 105 | 
            +
                    segments: 
         | 
| 106 | 
            +
                    - 1
         | 
| 107 | 
            +
                    - 0
         | 
| 108 | 
            +
                    - 0
         | 
| 109 | 
            +
                    version: 1.0.0
         | 
| 110 | 
            +
              requirement: *id006
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 112 | 
            +
              prerelease: false
         | 
| 113 | 
            +
              type: :development
         | 
| 114 | 
            +
              name: jeweler
         | 
| 115 | 
            +
              version_requirements: &id007 !ruby/object:Gem::Requirement 
         | 
| 116 | 
            +
                none: false
         | 
| 117 | 
            +
                requirements: 
         | 
| 118 | 
            +
                - - ~>
         | 
| 119 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 120 | 
            +
                    hash: 7
         | 
| 121 | 
            +
                    segments: 
         | 
| 122 | 
            +
                    - 1
         | 
| 123 | 
            +
                    - 5
         | 
| 124 | 
            +
                    - 2
         | 
| 125 | 
            +
                    version: 1.5.2
         | 
| 126 | 
            +
              requirement: *id007
         | 
| 127 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 128 | 
            +
              prerelease: false
         | 
| 129 | 
            +
              type: :development
         | 
| 130 | 
            +
              name: rcov
         | 
| 131 | 
            +
              version_requirements: &id008 !ruby/object:Gem::Requirement 
         | 
| 132 | 
            +
                none: false
         | 
| 133 | 
            +
                requirements: 
         | 
| 134 | 
            +
                - - ">="
         | 
| 135 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 136 | 
            +
                    hash: 3
         | 
| 137 | 
            +
                    segments: 
         | 
| 138 | 
            +
                    - 0
         | 
| 139 | 
            +
                    version: "0"
         | 
| 140 | 
            +
              requirement: *id008
         | 
| 141 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 142 | 
            +
              prerelease: false
         | 
| 143 | 
            +
              type: :development
         | 
| 144 | 
            +
              name: vcr
         | 
| 145 | 
            +
              version_requirements: &id009 !ruby/object:Gem::Requirement 
         | 
| 146 | 
            +
                none: false
         | 
| 147 | 
            +
                requirements: 
         | 
| 148 | 
            +
                - - ">="
         | 
| 149 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 150 | 
            +
                    hash: 3
         | 
| 151 | 
            +
                    segments: 
         | 
| 152 | 
            +
                    - 0
         | 
| 153 | 
            +
                    version: "0"
         | 
| 154 | 
            +
              requirement: *id009
         | 
| 155 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 156 | 
            +
              prerelease: false
         | 
| 157 | 
            +
              type: :development
         | 
| 158 | 
            +
              name: webmock
         | 
| 159 | 
            +
              version_requirements: &id010 !ruby/object:Gem::Requirement 
         | 
| 160 | 
            +
                none: false
         | 
| 161 | 
            +
                requirements: 
         | 
| 162 | 
            +
                - - ">="
         | 
| 163 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 164 | 
            +
                    hash: 3
         | 
| 165 | 
            +
                    segments: 
         | 
| 166 | 
            +
                    - 0
         | 
| 167 | 
            +
                    version: "0"
         | 
| 168 | 
            +
              requirement: *id010
         | 
| 169 | 
            +
            description: A Ruby wrapper for the Zferral API, based on HTTParty.
         | 
| 170 | 
            +
            email: michael@webadvocate.com
         | 
| 171 | 
            +
            executables: []
         | 
| 172 | 
            +
             | 
| 173 | 
            +
            extensions: []
         | 
| 174 | 
            +
             | 
| 175 | 
            +
            extra_rdoc_files: 
         | 
| 176 | 
            +
            - LICENSE.txt
         | 
| 177 | 
            +
            - README.rdoc
         | 
| 178 | 
            +
            files: 
         | 
| 179 | 
            +
            - .document
         | 
| 180 | 
            +
            - .rspec
         | 
| 181 | 
            +
            - Gemfile
         | 
| 182 | 
            +
            - Gemfile.lock
         | 
| 183 | 
            +
            - LICENSE.txt
         | 
| 184 | 
            +
            - README.rdoc
         | 
| 185 | 
            +
            - Rakefile
         | 
| 186 | 
            +
            - VERSION
         | 
| 187 | 
            +
            - lib/zferral.rb
         | 
| 188 | 
            +
            - lib/zferral/client.rb
         | 
| 189 | 
            +
            - lib/zferral/errors.rb
         | 
| 190 | 
            +
            - lib/zferral/resource.rb
         | 
| 191 | 
            +
            - lib/zferral/resources/campaign.rb
         | 
| 192 | 
            +
            - lib/zferral/resources/event.rb
         | 
| 193 | 
            +
            - spec/campaign_spec.rb
         | 
| 194 | 
            +
            - spec/event_spec.rb
         | 
| 195 | 
            +
            - spec/spec_helper.rb
         | 
| 196 | 
            +
            - spec/support/matchers/be.rb
         | 
| 197 | 
            +
            - spec/vcr_cassettes/campaigns.yml
         | 
| 198 | 
            +
            - spec/vcr_cassettes/events.yml
         | 
| 199 | 
            +
            - spec/zferral_spec.rb
         | 
| 200 | 
            +
            - zferral.gemspec
         | 
| 201 | 
            +
            has_rdoc: true
         | 
| 202 | 
            +
            homepage: http://github.com/grasshopperlabs/zferral
         | 
| 203 | 
            +
            licenses: 
         | 
| 204 | 
            +
            - MIT
         | 
| 205 | 
            +
            post_install_message: 
         | 
| 206 | 
            +
            rdoc_options: []
         | 
| 207 | 
            +
             | 
| 208 | 
            +
            require_paths: 
         | 
| 209 | 
            +
            - lib
         | 
| 210 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 211 | 
            +
              none: false
         | 
| 212 | 
            +
              requirements: 
         | 
| 213 | 
            +
              - - ">="
         | 
| 214 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 215 | 
            +
                  hash: 3
         | 
| 216 | 
            +
                  segments: 
         | 
| 217 | 
            +
                  - 0
         | 
| 218 | 
            +
                  version: "0"
         | 
| 219 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 220 | 
            +
              none: false
         | 
| 221 | 
            +
              requirements: 
         | 
| 222 | 
            +
              - - ">="
         | 
| 223 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 224 | 
            +
                  hash: 3
         | 
| 225 | 
            +
                  segments: 
         | 
| 226 | 
            +
                  - 0
         | 
| 227 | 
            +
                  version: "0"
         | 
| 228 | 
            +
            requirements: []
         | 
| 229 | 
            +
             | 
| 230 | 
            +
            rubyforge_project: 
         | 
| 231 | 
            +
            rubygems_version: 1.3.7
         | 
| 232 | 
            +
            signing_key: 
         | 
| 233 | 
            +
            specification_version: 3
         | 
| 234 | 
            +
            summary: A Ruby wrapper for the Zferral API
         | 
| 235 | 
            +
            test_files: 
         | 
| 236 | 
            +
            - spec/campaign_spec.rb
         | 
| 237 | 
            +
            - spec/event_spec.rb
         | 
| 238 | 
            +
            - spec/spec_helper.rb
         | 
| 239 | 
            +
            - spec/support/matchers/be.rb
         | 
| 240 | 
            +
            - spec/zferral_spec.rb
         |