From 47fbdb58e3cdf554c7e8c3950e47565120ecd773 Mon Sep 17 00:00:00 2001 From: Ary Rabelo Date: Sat, 13 Apr 2019 16:53:41 -0300 Subject: [PATCH 1/3] Update connection.rb --- lib/namely/connection.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/namely/connection.rb b/lib/namely/connection.rb index 68e0b6b..7d00965 100644 --- a/lib/namely/connection.rb +++ b/lib/namely/connection.rb @@ -77,15 +77,17 @@ def profiles def reports collection("reports") end + + + def collection(endpoint, options = {}) + Namely::Collection.new(gateway(endpoint, options)) + end + private attr_reader :access_token, :subdomain - def collection(endpoint, options = {}) - Namely::Collection.new(gateway(endpoint, options)) - end - def gateway(endpoint, options = {}) ResourceGateway.new(options.merge( access_token: access_token, From 600d3e52e76e6b67569773c81a16dd5c43f43742 Mon Sep 17 00:00:00 2001 From: Ary Rabelo Date: Tue, 16 Apr 2019 20:18:17 -0300 Subject: [PATCH 2/3] Add Group_types --- lib/namely/connection.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/namely/connection.rb b/lib/namely/connection.rb index 7d00965..63e7616 100644 --- a/lib/namely/connection.rb +++ b/lib/namely/connection.rb @@ -50,6 +50,13 @@ def fields collection("profiles/fields") end + # Return a Collection of job tiers. + # + # @return [Collection] + def job_tiers + collection("group_types") + end + # Return a Collection of job tiers. # # @return [Collection] From cdf64ea5807853b81e4a0286c025b89590c9fd84 Mon Sep 17 00:00:00 2001 From: Ary Rabelo Date: Tue, 16 Apr 2019 23:15:13 -0300 Subject: [PATCH 3/3] Add group_types and find from --- lib/namely/collection.rb | 6 ++++++ lib/namely/connection.rb | 6 ++---- lib/namely/resource_gateway.rb | 4 ++++ lib/namely/version.rb | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/namely/collection.rb b/lib/namely/collection.rb index 3c93e53..0febaf5 100644 --- a/lib/namely/collection.rb +++ b/lib/namely/collection.rb @@ -71,6 +71,12 @@ def find(id) raise NoSuchModelError, "Can't find any #{endpoint} with id \"#{id}\"" end + def find_from(id, find_from=nil) + resource_gateway.json_find_from(id, find_from).map { |model| build(model) } + rescue RestClient::ResourceNotFound + raise NoSuchModelError, "Can't find any #{endpoint} with id \"#{id}\"" + end + private attr_reader :resource_gateway diff --git a/lib/namely/connection.rb b/lib/namely/connection.rb index 63e7616..fe0a5a9 100644 --- a/lib/namely/connection.rb +++ b/lib/namely/connection.rb @@ -53,7 +53,7 @@ def fields # Return a Collection of job tiers. # # @return [Collection] - def job_tiers + def group_types collection("group_types") end @@ -84,13 +84,11 @@ def profiles def reports collection("reports") end - - + def collection(endpoint, options = {}) Namely::Collection.new(gateway(endpoint, options)) end - private attr_reader :access_token, :subdomain diff --git a/lib/namely/resource_gateway.rb b/lib/namely/resource_gateway.rb index f578b51..bad4a9f 100644 --- a/lib/namely/resource_gateway.rb +++ b/lib/namely/resource_gateway.rb @@ -13,6 +13,10 @@ def json_index paged ? json_index_paged : json_index_all end + def json_find_from(id, find_from) + get("/#{endpoint}/#{id}/#{find_from}")[find_from] + end + def json_show(id) get("/#{endpoint}/#{id}")[resource_name].first end diff --git a/lib/namely/version.rb b/lib/namely/version.rb index 57c7498..e277e84 100644 --- a/lib/namely/version.rb +++ b/lib/namely/version.rb @@ -1,3 +1,3 @@ module Namely - VERSION = '0.2.5' + VERSION = '0.2.5.17' end