Skip to content

Commit

Permalink
Merge pull request #1 from Root-App/corey-add-stuff
Browse files Browse the repository at this point in the history
Corey add stuff
  • Loading branch information
coreycarvalho committed Jun 21, 2019
2 parents f957743 + 7773fac commit e7a6719
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.3
14 changes: 9 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
app_store_connect (0.1.0)
app_store_connect (0.2.0)
gli (~> 2.17)
httparty (~> 0.16)
jwt (~> 2.1)
Expand All @@ -11,11 +11,15 @@ GEM
specs:
coderay (1.1.2)
diff-lcs (1.3)
gli (2.17.1)
httparty (0.16.2)
gli (2.18.0)
httparty (0.17.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
jwt (2.1.0)
jwt (2.2.1)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.0331)
multi_xml (0.6.0)
pry (0.12.2)
coderay (~> 1.1.0)
Expand Down Expand Up @@ -46,4 +50,4 @@ DEPENDENCIES
rspec (~> 3.0)

BUNDLED WITH
2.0.1
2.0.2
1 change: 1 addition & 0 deletions lib/app_store_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "app_store_connect/authorization"
require "app_store_connect/client"
require "app_store_connect/cli"
require "app_store_connect/user_invitation_create_request"
require "app_store_connect/version"

module AppStoreConnect
Expand Down
23 changes: 20 additions & 3 deletions lib/app_store_connect/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@ def build(app_id, build_id)
get("apps/#{app_id}/builds/#{build_id}")
end

def invite_user(first_name:, last_name:, email:, roles:)
invitation = UserInvitationCreateRequest.new(
:first_name => first_name,
:last_name => last_name,
:email => email,
:roles => roles
)

post("userInvitations", invitation.body.to_json)
end

def users
get("users")
end
end

def user_invitations
get("userInvitations")
end
end

private

Expand All @@ -42,8 +53,14 @@ def get(path)
response["data"]
end

def post(path, body)
response = HTTParty.post("#{ENDPOINT}/#{path}", headers: headers, body: body)

response
end

def headers
{ "Authorization" => "Bearer #{@authorization.token}" }
{ "Authorization" => "Bearer #{@authorization.token}", "Content-Type" => "application/json" }
end
end
end
15 changes: 15 additions & 0 deletions lib/app_store_connect/user_invitation_create_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module AppStoreConnect
class UserInvitationCreateRequest < Struct.new(:first_name, :last_name, :email, :roles)
def body
{ "data" =>
{ "type" => "userInvitations", "attributes" =>
{ "firstName" => @first_name, "lastName" => @last_name, "email" => @email, "roles" => @roles, "allAppsVisible" => true, "provisioningAllowed" => true }
}
}
end

def to_s
body.to_json
end
end
end

0 comments on commit e7a6719

Please sign in to comment.