Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintained Fork? #48

Open
Meekohi opened this issue Nov 22, 2016 · 4 comments
Open

Maintained Fork? #48

Meekohi opened this issue Nov 22, 2016 · 4 comments

Comments

@Meekohi
Copy link
Contributor

Meekohi commented Nov 22, 2016

Hey this project has pretty clearly been abandoned by the owner based on the number of ignored Pull Requests for simple things like the now mandatory HTTPS endpoints. Does someone want to step up and declare their fork as an "official" descendant fork, with a promise to maintain it going forward (with help from the community, of course)?

@TrevorHinesley
Copy link

This fork seems like the way to go if @VincentJaouen is willing to maintain:

https://github.com/VincentJaouen/pipedrive-ruby

@VincentJaouen
Copy link

Hey, sure I'll be happy to maintain the project

@januszm
Copy link

januszm commented Oct 28, 2018

@VincentJaouen are you able to push new releases of this gem to rubygems.org ?

@x-yuri
Copy link

x-yuri commented Oct 2, 2020

Yeah, at least updates are working with VincentJaouen/pipedrive-ruby. @VincentJaouen you could update the Installation section:

gem 'pipedrive-ruby', github: 'VincentJaouen/pipedrive-ruby'

UPD And with the following patch:

module Pipedrive
  class Base < OpenStruct
    class << self
      def all(response = nil, options={},get_absolutely_all=false)
        res = response ? response.call(options) : get(resource_path, options)
        if res.ok?
          data = res['data'].nil? ? [] : res['data'].map{|obj| new(obj)}
pp data.map { |f| f.name }
          if get_absolutely_all && res['additional_data']['pagination'] && res['additional_data']['pagination'] && res['additional_data']['pagination']['more_items_in_collection']
            options[:query] = options[:query].merge({:start => res['additional_data']['pagination']['next_start']})
            data += self.all(response,options,true)
          end
          data
        else
          bad_response(res,attrs)
        end
      end
    end
  end

  class Deal < Base
    def files(options = {}, get_absolutely_all=false)
      File.all(->(options) { get("#{resource_path}/#{id}/files", options) }, options, get_absolutely_all)
    end
  end
end

you can obtain all the files:

Pipedrive::Deal.find(id).files({}, true)

Although it's best to do something along the lines of what pipedrive.rb does.

E.g.:

module Pipedrive
  class Deal < Base
    def each_file
      return to_enum(:each_file) unless block_given?
      follow_pagination { |f| yield f }
    end

    def follow_pagination
      options = {query: {start: 0, limit: 1}}
      loop do
        res = get("#{resource_path}/#{id}/files", options)
        return bad_response(res) unless res.ok?
        res['data'].each do |f|
          yield File.new(f)
        end
        break unless res.dig('additional_data', 'pagination', 'more_items_in_collection')
        options[:query][:start] = res.dig('additional_data', 'pagination', 'next_start')
      end
    end
  end
end

Pipedrive::Deal.find(id).each_file do |f|
  puts f.name
end

bug at base.rb: attrs -> options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants