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

Fix #45 - Rename global method to a library-specific name, to avoid interfering with other libraries #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/asana/authentication/oauth2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ module OAuth2
#
# Note: This function reads from STDIN and writes to STDOUT. It is meant
# to be used only within the context of a CLI application.
def offline_flow(client_id: required('client_id'),
client_secret: required('client_secret'))
def offline_flow(client_id: asana_arg_required('client_id'),
client_secret: asana_arg_required('client_secret'))
client = Client.new(client_id: client_id,
client_secret: client_secret,
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class AccessTokenAuthentication
# Returns an [AccessTokenAuthentication] instance with a refreshed
# access token.
def self.from_refresh_token(refresh_token,
client_id: required('client_id'),
client_secret: required('client_secret'),
redirect_uri: required('redirect_uri'))
client_id: asana_arg_required('client_id'),
client_secret: asana_arg_required('client_secret'),
redirect_uri: asana_arg_required('redirect_uri'))
client = Client.new(client_id: client_id,
client_secret: client_secret,
redirect_uri: redirect_uri)
Expand Down
6 changes: 3 additions & 3 deletions lib/asana/authentication/oauth2/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class Client
# application
# redirect_uri - [String] a redirect uri from the registered
# application
def initialize(client_id: required('client_id'),
client_secret: required('client_secret'),
redirect_uri: required('redirect_uri'))
def initialize(client_id: asana_arg_required('client_id'),
client_secret: asana_arg_required('client_secret'),
redirect_uri: asana_arg_required('redirect_uri'))
@client = ::OAuth2::Client.new(client_id, client_secret,
site: 'https://app.asana.com',
authorize_url: '/-/oauth_authorize',
Expand Down
2 changes: 1 addition & 1 deletion lib/asana/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Client
# Internal: Proxies Resource classes to implement a fluent API on the Client
# instances.
class ResourceProxy
def initialize(client: required('client'), resource: required('resource'))
def initialize(client: asana_arg_required('client'), resource: asana_arg_required('resource'))
@client = client
@resource = resource
end
Expand Down
2 changes: 1 addition & 1 deletion lib/asana/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HttpClient
# user_agent - [String] The user agent. Defaults to "ruby-asana vX.Y.Z".
# config - [Proc] An optional block that yields the Faraday builder
# object for customization.
def initialize(authentication: required('authentication'),
def initialize(authentication: asana_arg_required('authentication'),
adapter: nil,
user_agent: nil,
debug_mode: false,
Expand Down
4 changes: 2 additions & 2 deletions lib/asana/resource_includes/attachment_uploading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module AttachmentUploading
#
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def attach(filename: required('filename'),
mime: required('mime'),
def attach(filename: asana_arg_required('filename'),
mime: asana_arg_required('mime'),
options: {}, **data)
path = File.expand_path(filename)
unless File.exist?(path)
Expand Down
2 changes: 1 addition & 1 deletion lib/asana/resource_includes/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Collection
# client - [Asana::Client] the client to perform requests.
def initialize((elements, extra),
type: Resource,
client: required('client'))
client: asana_arg_required('client'))
@elements = elements.map { |elem| type.new(elem, client: client) }
@type = type
@next_page_data = extra['next_page']
Expand Down
4 changes: 2 additions & 2 deletions lib/asana/resource_includes/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Events
# client - [Asana::Client] a client to perform the requests.
# wait - [Integer] the number of seconds to wait between each poll.
# options - [Hash] the request I/O options
def initialize(resource: required('resource'),
client: required('client'),
def initialize(resource: asana_arg_required('resource'),
client: asana_arg_required('client'),
wait: 1, options: {})
@resource = resource
@client = client
Expand Down
2 changes: 1 addition & 1 deletion lib/asana/resource_includes/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.inherited(base)
Registry.register(base)
end

def initialize(data, client: required('client'))
def initialize(data, client: asana_arg_required('client'))
@_client = client
@_data = data
data.each do |k, v|
Expand Down
2 changes: 1 addition & 1 deletion lib/asana/resources/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def find_by_id(client, id, options: {})
#
# per_page - [Integer] the number of records to fetch per page.
# options - [Hash] the request I/O options.
def find_by_task(client, task: required("task"), per_page: 20, options: {})
def find_by_task(client, task: asana_arg_required("task"), per_page: 20, options: {})
params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
Collection.new(parse(client.get("/tasks/#{task}/attachments", params: params, options: options)), type: self, client: client)
end
Expand Down
16 changes: 8 additions & 8 deletions lib/asana/resources/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def plural_name
#
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def create(client, workspace: required("workspace"), team: nil, options: {}, **data)
def create(client, workspace: asana_arg_required("workspace"), team: nil, options: {}, **data)
with_params = data.merge(workspace: workspace, team: team).reject { |_,v| v.nil? || Array(v).empty? }
self.new(parse(client.post("/projects", body: with_params, options: options)).first, client: client)
end
Expand All @@ -83,7 +83,7 @@ def create(client, workspace: required("workspace"), team: nil, options: {}, **d
# workspace - [Id] The workspace or organization to create the project in.
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def create_in_workspace(client, workspace: required("workspace"), options: {}, **data)
def create_in_workspace(client, workspace: asana_arg_required("workspace"), options: {}, **data)

self.new(parse(client.post("/workspaces/#{workspace}/projects", body: data, options: options)).first, client: client)
end
Expand All @@ -95,7 +95,7 @@ def create_in_workspace(client, workspace: required("workspace"), options: {}, *
# team - [Id] The team to create the project in.
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def create_in_team(client, team: required("team"), options: {}, **data)
def create_in_team(client, team: asana_arg_required("team"), options: {}, **data)

self.new(parse(client.post("/teams/#{team}/projects", body: data, options: options)).first, client: client)
end
Expand Down Expand Up @@ -132,7 +132,7 @@ def find_all(client, workspace: nil, team: nil, archived: nil, per_page: 20, opt
#
# per_page - [Integer] the number of records to fetch per page.
# options - [Hash] the request I/O options.
def find_by_workspace(client, workspace: required("workspace"), archived: nil, per_page: 20, options: {})
def find_by_workspace(client, workspace: asana_arg_required("workspace"), archived: nil, per_page: 20, options: {})
params = { archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
Collection.new(parse(client.get("/workspaces/#{workspace}/projects", params: params, options: options)), type: self, client: client)
end
Expand All @@ -145,7 +145,7 @@ def find_by_workspace(client, workspace: required("workspace"), archived: nil, p
#
# per_page - [Integer] the number of records to fetch per page.
# options - [Hash] the request I/O options.
def find_by_team(client, team: required("team"), archived: nil, per_page: 20, options: {})
def find_by_team(client, team: asana_arg_required("team"), archived: nil, per_page: 20, options: {})
params = { archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
Collection.new(parse(client.get("/teams/#{team}/projects", params: params, options: options)), type: self, client: client)
end
Expand Down Expand Up @@ -203,7 +203,7 @@ def tasks(per_page: 20, options: {})
# followers - [Array] An array of followers to add to the project.
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def add_followers(followers: required("followers"), options: {}, **data)
def add_followers(followers: asana_arg_required("followers"), options: {}, **data)
with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? }
refresh_with(parse(client.post("/projects/#{id}/addFollowers", body: with_params, options: options)).first)
end
Expand All @@ -214,7 +214,7 @@ def add_followers(followers: required("followers"), options: {}, **data)
# followers - [Array] An array of followers to remove from the project.
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def remove_followers(followers: required("followers"), options: {}, **data)
def remove_followers(followers: asana_arg_required("followers"), options: {}, **data)
with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? }
refresh_with(parse(client.post("/projects/#{id}/removeFollowers", body: with_params, options: options)).first)
end
Expand All @@ -224,7 +224,7 @@ def remove_followers(followers: required("followers"), options: {}, **data)
# members - [Array] An array of members to add to the project.
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def add_members(members: required("members"), options: {}, **data)
def add_members(members: asana_arg_required("members"), options: {}, **data)
with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? }
refresh_with(parse(client.post("/projects/#{id}/addMembers", body: with_params, options: options)).first)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/asana/resources/story.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def plural_name
#
# per_page - [Integer] the number of records to fetch per page.
# options - [Hash] the request I/O options.
def find_by_task(client, task: required("task"), per_page: 20, options: {})
def find_by_task(client, task: asana_arg_required("task"), per_page: 20, options: {})
params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
Collection.new(parse(client.get("/tasks/#{task}/stories", params: params, options: options)), type: self, client: client)
end
Expand All @@ -73,7 +73,7 @@ def find_by_id(client, id, options: {})
# text - [String] The plain text of the comment to add.
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def create_on_task(client, task: required("task"), text: required("text"), options: {}, **data)
def create_on_task(client, task: asana_arg_required("task"), text: asana_arg_required("text"), options: {}, **data)
with_params = data.merge(text: text).reject { |_,v| v.nil? || Array(v).empty? }
self.new(parse(client.post("/tasks/#{task}/stories", body: with_params, options: options)).first, client: client)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/asana/resources/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def plural_name
# workspace - [Id] The workspace or organization to create the tag in.
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def create(client, workspace: required("workspace"), options: {}, **data)
def create(client, workspace: asana_arg_required("workspace"), options: {}, **data)
with_params = data.merge(workspace: workspace).reject { |_,v| v.nil? || Array(v).empty? }
self.new(parse(client.post("/tags", body: with_params, options: options)).first, client: client)
end
Expand All @@ -62,7 +62,7 @@ def create(client, workspace: required("workspace"), options: {}, **data)
# workspace - [Id] The workspace or organization to create the tag in.
# options - [Hash] the request I/O options.
# data - [Hash] the attributes to post.
def create_in_workspace(client, workspace: required("workspace"), options: {}, **data)
def create_in_workspace(client, workspace: asana_arg_required("workspace"), options: {}, **data)

self.new(parse(client.post("/workspaces/#{workspace}/tags", body: data, options: options)).first, client: client)
end
Expand Down Expand Up @@ -96,7 +96,7 @@ def find_all(client, workspace: nil, team: nil, archived: nil, per_page: 20, opt
# workspace - [Id] The workspace or organization to find tags in.
# per_page - [Integer] the number of records to fetch per page.
# options - [Hash] the request I/O options.
def find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {})
def find_by_workspace(client, workspace: asana_arg_required("workspace"), per_page: 20, options: {})
params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
Collection.new(parse(client.get("/workspaces/#{workspace}/tags", params: params, options: options)), type: self, client: client)
end
Expand Down
Loading