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

remove preview API warning for team memberships API #518

Merged
merged 2 commits into from
Oct 10, 2014
Merged
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
27 changes: 0 additions & 27 deletions lib/octokit/client/organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ class Client
# @see https://developer.github.com/v3/orgs/
module Organizations

ORG_INVITATIONS_PREVIEW_MEDIA_TYPE = "application/vnd.github.the-wasp-preview+json".freeze

# Get an organization
#
# @param org [String, Integer] Organization GitHub login or id.
Expand Down Expand Up @@ -498,7 +496,6 @@ def user_teams(options = {})
# @example Check if a user has a membership for a team
# @client.team_membership(1234, 'pengwynn')
def team_membership(team_id, user, options = {})
options = ensure_org_invitations_api_media_type(options)
get "teams/#{team_id}/memberships/#{user}", options
end

Expand All @@ -514,7 +511,6 @@ def team_membership(team_id, user, options = {})
# @example Check if a user has a membership for a team
# @client.add_team_membership(1234, 'pengwynn')
def add_team_membership(team_id, user, options = {})
options = ensure_org_invitations_api_media_type(options)
put "teams/#{team_id}/memberships/#{user}", options
end

Expand All @@ -527,7 +523,6 @@ def add_team_membership(team_id, user, options = {})
# @example
# @client.remove_team_membership(100000, 'pengwynn')
def remove_team_membership(team_id, user, options = {})
options = ensure_org_invitations_api_media_type(options)
boolean_from_response :delete, "teams/#{team_id}/memberships/#{user}", options
end

Expand All @@ -536,7 +531,6 @@ def remove_team_membership(team_id, user, options = {})
# @return [Array<Sawyer::Resource>] Array of organizations memberships.
# @see https://developer.github.com/v3/orgs/members/#list-your-organization-memberships
def organization_memberships(options = {})
options = ensure_org_invitations_api_media_type(options)
paginate "user/memberships/orgs", options
end
alias :org_memberships :organization_memberships
Expand All @@ -547,7 +541,6 @@ def organization_memberships(options = {})
# @return [Sawyer::Resource] Hash representing the organization membership.
# @see https://developer.github.com/v3/orgs/members/#get-your-organization-membership
def organization_membership(org, options = {})
options = ensure_org_invitations_api_media_type(options)
get "user/memberships/orgs/#{org}", options
end
alias :org_membership :organization_membership
Expand All @@ -559,29 +552,9 @@ def organization_membership(org, options = {})
# @return [Sawyer::Resource] Hash representing the updated organization membership.
# @see https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
def update_organization_membership(org, options = {})
options = ensure_org_invitations_api_media_type(options)
patch "user/memberships/orgs/#{org}", options
end
alias :update_org_membership :update_organization_membership

private

def ensure_org_invitations_api_media_type(options = {})
if options[:accept].nil?
options[:accept] = ORG_INVITATIONS_PREVIEW_MEDIA_TYPE
warn_org_invitations_preview
end

options
end

def warn_org_invitations_preview
octokit_warn \
"WARNING: The preview version of the Organization Team Memberships API " \
"is not yet suitable for production use. You can avoid this message by " \
"supplying an appropriate media type in the 'Accept' request header. " \
"See the blog post for details: http://git.io/a9jglQ"
end
end
end
end