lib/namely/resource_gateway.rb in namely-0.0.1 vs lib/namely/resource_gateway.rb in namely-0.1.0
- old
+ new
@@ -1,11 +1,12 @@
module Namely
class ResourceGateway
+ attr_reader :endpoint
+
def initialize(options)
@access_token = options.fetch(:access_token)
@endpoint = options.fetch(:endpoint)
- @resource_name = options.fetch(:resource_name)
@subdomain = options.fetch(:subdomain)
end
def json_index
get("/#{endpoint}", limit: :all)[resource_name]
@@ -31,10 +32,14 @@
put("/#{endpoint}/#{id}", endpoint => [changes])
end
private
- attr_reader :access_token, :endpoint, :resource_name, :subdomain
+ attr_reader :access_token, :subdomain
+
+ def resource_name
+ endpoint.split("/").last
+ end
def url(path)
"https://#{subdomain}.namely.com/api/v1#{path}"
end