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

client.meta.users #36

Closed
bitxpert opened this issue Jun 5, 2017 · 3 comments
Closed

client.meta.users #36

bitxpert opened this issue Jun 5, 2017 · 3 comments

Comments

@bitxpert
Copy link

bitxpert commented Jun 5, 2017

Hi
Following function is not working as expected.

client.meta.users

Getting this exception from gem
NoMethodError: undefined method []' for nil:NilClass from /home/zee/.rvm/gems/ruby-2.3.3/gems/bamboozled-0.1.0/lib/bamboozled/api/meta.rb:8:in block (2 levels) in class:Meta'
from (irb):280

Hope you will fix it

Thanks

@jonmagic
Copy link

jonmagic commented Jun 7, 2017

I ran into this today so I cloned the gem and added a binding.pry here so I could inspect the returned results:

module Bamboozled
  module API
    class Meta < Base

      [:field, :table, :list, :user].each do |action|
        define_method("#{action}s") do
          result = request(:get, "meta/#{action}s")
          require "pry"; binding.pry
          result["#{action}s".to_sym][action]
        end
      end

    end
  end
end

I then tested each of the defined methods and found:

  • client.meta.fields returns an Array and will not work with result["#{action}s".to_sym][action]
  • client.meta.tables errors out for me with an invalid date error in the xml parser, could be something to do with my companies Bamboo setup. Anyways, couldn't figure out what the result shape looks like but according to the docs it should be nested such that result["#{action}s".to_sym][action] would work.
  • client.meta.lists works as advertised with result["#{action}s".to_sym][action].
  • client.meta.users returns a Hash keyed by the id value of the user, so this will not work with result["#{action}s".to_sym][action].

I'm going to cut a PR that fixes client.meta.fields and client.meta.users. Probably won't have tests in my first draft of the PR because I want to just get a commit out there I can test manually with.

@bitxpert
Copy link
Author

bitxpert commented Jun 8, 2017

@mjording thanks for giving this solution.
I am doing this by placing a file in config/initializers directory

Bamboo hr api has no any explanation about this.
I need confirmation that is this 'client.meta.users' return all users in a company including terminated,deleted as well?

@bitxpert
Copy link
Author

bitxpert commented Jun 8, 2017

@mjording
Here is an example to get terminated employee.
I've test but not getting terminated users.

https://github.com/Skookum/bamboozled/blob/master/examples/employees_over_time.rb

ruprict added a commit that referenced this issue Feb 16, 2018
The issue stems from the various ways the Bamboo HR API returns results
for the metadata endpoints. The original code tried to handle it with
metaprogramming, but the returning results are not the same.

Added tests and methods specific to the four metadata endpoints.

Address [Issue #36](#36)
ruprict added a commit that referenced this issue Feb 17, 2018
Fix Issue #36: client.meta.users failing
@ruprict ruprict closed this as completed Mar 9, 2018
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

Successfully merging a pull request may close this issue.

3 participants