Sha256: ce21db4497346eae9cca6a83e0235455383a510a88194e33f05db5a20a24fa74

Contents?: true

Size: 1.56 KB

Versions: 23

Compression:

Stored size: 1.56 KB

Contents

require 'hubspot/utils'

module Hubspot
  #
  # HubSpot Deals API
  #
  # {http://developers.hubspot.com/docs/methods/deal-pipelines/overview}
  #
  class DealPipeline
    PIPELINES_PATH = "/deals/v1/pipelines"
    PIPELINE_PATH = "/deals/v1/pipelines/:pipeline_id"

    attr_reader :active
    attr_reader :display_order
    attr_reader :label
    attr_reader :pipeline_id
    attr_reader :stages

    def initialize(response_hash)
      @active = response_hash["active"]
      @display_order = response_hash["displayOrder"]
      @label = response_hash["label"]
      @pipeline_id = response_hash["pipelineId"]
      @stages = response_hash["stages"]
    end

    class << self
      def find(pipeline_id)
        response = Hubspot::Connection.get_json(PIPELINE_PATH, { pipeline_id: pipeline_id })
        new(response)
      end

      def all
        response = Hubspot::Connection.get_json(PIPELINES_PATH, {})
        response.map { |p| new(p) }
      end

      # Creates a DealPipeline
      # {https://developers.hubspot.com/docs/methods/deal-pipelines/create-deal-pipeline}
      # @return [Hubspot::PipeLine] Company record
      def create!(post_data={})
        response = Hubspot::Connection.post_json(PIPELINES_PATH, params: {}, body: post_data)
        new(response)
      end
    end

    # Destroys deal_pipeline
    # {http://developers.hubspot.com/docs/methods/companies/delete_company}
    # @return [TrueClass] true
    def destroy!
      Hubspot::Connection.delete_json(PIPELINE_PATH, pipeline_id: @pipeline_id)
    end

    def [](stage)
      @stages[stage]
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
hubspot-api-ruby-0.19.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.18.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.17.1 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.17.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.16.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.15.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.14.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.13.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.12.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.11.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.10.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.9.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.8.1 lib/hubspot/deal_pipeline.rb
hubspot-ruby-0.9.0 lib/hubspot/deal_pipeline.rb
hubspot-api-ruby-0.8.0 lib/hubspot/deal_pipeline.rb
hubspot-ruby-0.8.1 lib/hubspot/deal_pipeline.rb
hubspot-ruby-0.8.0 lib/hubspot/deal_pipeline.rb
hubspot-ruby-0.7.0 lib/hubspot/deal_pipeline.rb
hubspot-ruby-0.6.1 lib/hubspot/deal_pipeline.rb
hubspot-ruby-0.6.0 lib/hubspot/deal_pipeline.rb