WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 51bac64

Browse files
committed
Add support for listing users
1 parent d52cd8e commit 51bac64

File tree

11 files changed

+79
-23
lines changed

11 files changed

+79
-23
lines changed

lib/connector_kit.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
require 'connector_kit/httpclient.rb'
22
require 'connector_kit/token_generator'
33
require 'connector_kit/version'
4-
require 'connector_kit/mappers/app_list_mapper'
5-
require 'connector_kit/mappers/build_list_mapper'
6-
require 'connector_kit/mappers/build_details_mapper'
4+
require 'connector_kit/mappers/app_list_response_mapper'
5+
require 'connector_kit/mappers/user_list_response_mapper'
6+
require 'connector_kit/mappers/build_list_response_mapper'
7+
require 'connector_kit/mappers/build_details_response_mapper'
78

89
module ConnectorKit
910
# Class used for communicating with the App Store Connect API
@@ -22,15 +23,22 @@ def initialize(issuer_id, key_id, private_key_file_path)
2223
end
2324

2425
def apps
25-
@httpclient.get '/apps', AppListMapper.new
26+
@httpclient.get '/apps', AppListResponseMapper.new
27+
end
28+
29+
def users
30+
@httpclient.get '/users', UserListResponseMapper.new
2631
end
2732

2833
def app_builds(app)
29-
@httpclient.get "/apps/#{app.id}/builds", BuildListMapper.new
34+
@httpclient.get "/apps/#{app.id}/builds", BuildListResponseMapper.new
3035
end
3136

3237
def build_beta_details(build)
33-
@httpclient.get "/buildBetaDetails/#{build.id}", BuildDetailsMapper.new
38+
@httpclient.get(
39+
"/buildBetaDetails/#{build.id}",
40+
BuildDetailsResponseMapper.new
41+
)
3442
end
3543
end
3644
end

lib/connector_kit/mappers/app_list_mapper.rb renamed to lib/connector_kit/mappers/app_list_response_mapper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ConnectorKit
44
# Mapper between a HTTParty response and a list of Apps
5-
class AppListMapper
5+
class AppListResponseMapper
66
def map(data)
77
data.map { |app| App.new(app) }
88
end

lib/connector_kit/mappers/build_details_mapper.rb renamed to lib/connector_kit/mappers/build_details_response_mapper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ConnectorKit
44
# Mapper between a HTTParty response and a BuildDetails object
5-
class BuildDetailsMapper
5+
class BuildDetailsResponseMapper
66
def map(data)
77
BuildDetails.new(data)
88
end

lib/connector_kit/mappers/build_list_mapper.rb renamed to lib/connector_kit/mappers/build_list_response_mapper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ConnectorKit
44
# Mapper between a HTTParty response and a list of Builds
5-
class BuildListMapper
5+
class BuildListResponseMapper
66
def map(data)
77
data.map { |build| Build.new(build) }
88
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'connector_kit/models/user'
2+
3+
module ConnectorKit
4+
# Mapper between a HTTParty response and a list of Users
5+
class UserListResponseMapper
6+
def map(data)
7+
data.map { |user| User.new(user) }
8+
end
9+
end
10+
end

lib/connector_kit/models/app.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
require 'connector_kit/models/model'
2+
13
module ConnectorKit
2-
# Simple model class for representing Apps in the App Store Connect API
3-
class App
4-
attr_reader :id, :bundle_id, :name, :sku
4+
# Simple model class for representing Apps
5+
class App < Model
6+
attr_reader :bundle_id, :name, :sku
57

68
def initialize(options)
7-
@id = options['id']
9+
super(options)
810

911
attrs = options['attributes']
1012
@bundle_id = attrs['bundleId']

lib/connector_kit/models/build.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
require 'connector_kit/models/model'
2+
13
module ConnectorKit
2-
# Simple model class for representing Builds in the App Store Connect API
3-
class Build
4-
attr_reader :id,
5-
:expired,
4+
# Simple model class for representing Builds
5+
class Build < Model
6+
attr_reader :expired,
67
:processing_state,
78
:version,
89
:uploaded_date,
910
:expiration_date
1011

1112
def initialize(options)
12-
@id = options['id']
13+
super(options)
1314

1415
attrs = options['attributes']
1516
@expired = attrs['expired']

lib/connector_kit/models/build_details.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
require 'connector_kit/models/model'
2+
13
module ConnectorKit
2-
# Simple model class for representing Build details in the App Store Connect API
3-
class BuildDetails
4-
attr_reader :id, :external_build_state, :internal_build_state
4+
# Simple model class for representing Build details
5+
class BuildDetails < Model
6+
attr_reader :external_build_state, :internal_build_state
57

68
def initialize(options)
7-
@id = options['id']
9+
super(options)
810

911
attrs = options['attributes']
1012
@external_build_state = attrs['externalBuildState']

lib/connector_kit/models/model.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module ConnectorKit
2+
# Base model for representing different entities
3+
class Model
4+
attr_reader :id
5+
6+
def initialize(options)
7+
@id = options['id']
8+
end
9+
end
10+
end

lib/connector_kit/models/user.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'connector_kit/models/model'
2+
3+
module ConnectorKit
4+
# Simple model class for representing Users in the App Store Connect API
5+
class User < Model
6+
attr_reader :first_name, :last_name, :username, :roles, :all_apps_visible
7+
8+
def initialize(options)
9+
super(options)
10+
11+
attrs = options['attributes']
12+
@first_name = attrs['firstName']
13+
@last_name = attrs['lastName']
14+
@username = attrs['username']
15+
@all_apps_visible = attrs['allAppsVisible']
16+
@roles = attrs['roles'].map { |role| role.downcase.to_sym }
17+
end
18+
19+
def full_name
20+
"#{@first_name} #{@last_name}"
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)