Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Added support for specifying the group for testers
Browse files Browse the repository at this point in the history
  • Loading branch information
KrauseFx committed Jul 18, 2015
1 parent 9a96114 commit 0219bf2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
6 changes: 4 additions & 2 deletions lib/spaceship/tunes/tester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ def find(identifier)
# @param email (String) (required): The email of the new tester
# @param first_name (String) (optional): The first name of the new tester
# @param last_name (String) (optional): The last name of the new tester
# @param group (String) (optional): The name of the group this tester should be added to
# @example
# Spaceship::Tunes::Tester.external.create!(email: "[email protected]", first_name: "Cary", last_name:"Bennett")
# @return (Tester): The newly created tester
def create!(email: nil, first_name: nil, last_name: nil)
def create!(email: nil, first_name: nil, last_name: nil, group: nil)
data = client.create_tester!(tester: self,
email: email,
first_name: first_name,
last_name: last_name)
last_name: last_name,
group: group)
self.factory(data)
end

Expand Down
20 changes: 14 additions & 6 deletions lib/spaceship/tunes/tunes_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,12 @@ def testers_by_app(tester, app_id)
parse_response(r, 'data')['users']
end

def create_tester!(tester: nil, email: nil, first_name: nil, last_name: nil)
# @param group (String) an optional group name
def create_tester!(tester: nil, email: nil, first_name: nil, last_name: nil, group: nil)
url = tester.url[:create]
raise "Action not provided for this tester type." unless url

data = {
testers: [
{
tester_data = {
emailAddress: {
value: email
},
Expand All @@ -272,8 +271,17 @@ def create_tester!(tester: nil, email: nil, first_name: nil, last_name: nil)
value: true
}
}
]
}

if group
tester_data[:groups] = [{
id: nil,
name: {
value: group
}
}]
end

data = { testers: [tester_data] }

r = request(:post) do |req|
req.url url
Expand Down

0 comments on commit 0219bf2

Please sign in to comment.