I've created my first gem as Instagram API wrapper https://github.com/agilie/instagram_api_gem. I would be very pleased if you give me some feedback on code organization, methods elegancy and so on.
The thing I concerned about the most is next. I have a module Resource
module Resource
include Client
private
def show(id, options = {})
raise 'Resource ID is required' unless id
make_request resource_path(id), query: options
end
def index(id, resource_name, options = {})
raise 'Resource ID is required' unless id
make_request resource_path("#{id}/#{resource_name}"), query: options
end
def create(id, resource_name, options = {})
raise 'Resource ID is required' unless id
make_request(resource_path("#{id}/#{resource_name}"), { body: options }, :post)
end
def destroy(id, resource_name, resource_id = nil, options = {})
raise 'Resource ID is required' unless id
path = "#{id}/#{resource_name}"
path = "#{path}/#{resource_id}" if resource_id
make_request(resource_path(path), { query: options }, :delete)
end
end
And I use methods from it like this
class Tag
include Search
include Resource
def initialize(tag_id = nil)
@tag_id = tag_id
end
def recent_media(options = {})
index @tag_id, 'media/recent', options
end
end
Does this implementation look good or are there more elegant solutions? I would be very pleased if you give me some feedback regarding the whole code organization and implementation, which could be found here https://github.com/agilie/instagram_api_gem
You are welcome to contribute if you prefer.