From 6adf7ccfa1f1213f28b56cb1dd17d7d9c230e925 Mon Sep 17 00:00:00 2001 From: Ian Koerich Maciel Date: Tue, 25 Oct 2022 09:03:07 -0300 Subject: [PATCH 1/7] Implement create repository from template Implement the service to create a new repo using a template according https://docs.github.com/en/rest/repos/repos#create-a-repository-using-a-template specs (endpoint: /repos/{template_owner}/{template_repo}/generate) --- lib/src/common/model/repos.dart | 33 +++++++++++++++++++++++++++++++ lib/src/common/model/repos.g.dart | 20 +++++++++++++++++++ lib/src/common/repos_service.dart | 15 ++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/lib/src/common/model/repos.dart b/lib/src/common/model/repos.dart index 739d6ca2..ce2f9ab0 100644 --- a/lib/src/common/model/repos.dart +++ b/lib/src/common/model/repos.dart @@ -379,6 +379,39 @@ class CreateRepository { Map toJson() => _$CreateRepositoryToJson(this); } +/// Model class for a new repository to be created using a template. +@JsonSerializable() +class CreateRepositoryFromTemplate { + CreateRepositoryFromTemplate( + this.name, { + this.owner, + this.description, + this.includeAllBranches, + this.private, + }); + + /// Repository Name + final String name; + + /// Owner Name + final String? owner; + + /// Repository Description + String? description; + + /// Include the directory structure and files from all branches in the + /// template repository, and not just the default branch. Default: false. + @JsonKey(name: 'include_all_branches') + bool? includeAllBranches = false; + + /// If the repository should be private or not. + bool? private = false; + + factory CreateRepositoryFromTemplate.fromJson(Map input) => + _$CreateRepositoryFromTemplateFromJson(input); + Map toJson() => _$CreateRepositoryFromTemplateToJson(this); +} + /// Model class for a branch. @JsonSerializable() class Branch { diff --git a/lib/src/common/model/repos.g.dart b/lib/src/common/model/repos.g.dart index 78184d6f..5bfa2e09 100644 --- a/lib/src/common/model/repos.g.dart +++ b/lib/src/common/model/repos.g.dart @@ -260,6 +260,26 @@ Map _$CreateRepositoryToJson(CreateRepository instance) => 'license_template': instance.licenseTemplate, }; +CreateRepositoryFromTemplate _$CreateRepositoryFromTemplateFromJson( + Map json) => + CreateRepositoryFromTemplate( + json['name'] as String, + owner: json['owner'] as String?, + description: json['description'] as String?, + includeAllBranches: json['include_all_branches'] as bool?, + private: json['private'] as bool?, + ); + +Map _$CreateRepositoryFromTemplateToJson( + CreateRepositoryFromTemplate instance) => + { + 'name': instance.name, + 'owner': instance.owner, + 'description': instance.description, + 'include_all_branches': instance.includeAllBranches, + 'private': instance.private, + }; + Branch _$BranchFromJson(Map json) => Branch( json['name'] as String?, json['commit'] == null diff --git a/lib/src/common/repos_service.dart b/lib/src/common/repos_service.dart index a3a73531..6fcc149b 100644 --- a/lib/src/common/repos_service.dart +++ b/lib/src/common/repos_service.dart @@ -118,6 +118,21 @@ class RepositoriesService extends Service { } } + /// Creates a repository with [repository] using a template. If an [org] is + /// specified, the new repository will be created under that organization. If + /// no [org] is specified, it will be created for the authenticated user. + /// + /// API docs: https://developer.github.com/v3/repos/#create + Future createRepositoryFromTemplate( + RepositorySlug template, CreateRepositoryFromTemplate repository) async { + ArgumentError.checkNotNull(repository); + return github.postJSON, Repository>( + '/repos/${template.fullName}/generate', + body: GitHubJson.encode(repository), + convert: (i) => Repository.fromJson(i), + ); + } + Future getLicense(RepositorySlug slug) async { ArgumentError.checkNotNull(slug); return github.getJSON, LicenseDetails>( From 344c841384080ee17c22c974acc4f03b97679c13 Mon Sep 17 00:00:00 2001 From: Ian Koerich Maciel Date: Tue, 25 Oct 2022 09:13:51 -0300 Subject: [PATCH 2/7] Add name parameter on create fork request https://docs.github.com/en/rest/repos/forks#create-a-fork --- lib/src/common/model/repos_forks.dart | 4 +++- lib/src/common/model/repos_forks.g.dart | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/common/model/repos_forks.dart b/lib/src/common/model/repos_forks.dart index cbf4b68c..70361138 100644 --- a/lib/src/common/model/repos_forks.dart +++ b/lib/src/common/model/repos_forks.dart @@ -2,11 +2,13 @@ import 'package:json_annotation/json_annotation.dart'; part 'repos_forks.g.dart'; /// Model class for a new fork to be created. +/// https://docs.github.com/en/rest/repos/forks#create-a-fork @JsonSerializable() class CreateFork { - CreateFork([this.organization]); + CreateFork({this.organization, this.name}); String? organization; + String? name; factory CreateFork.fromJson(Map input) => _$CreateForkFromJson(input); diff --git a/lib/src/common/model/repos_forks.g.dart b/lib/src/common/model/repos_forks.g.dart index 0d41f4e9..9944f67e 100644 --- a/lib/src/common/model/repos_forks.g.dart +++ b/lib/src/common/model/repos_forks.g.dart @@ -7,10 +7,12 @@ part of 'repos_forks.dart'; // ************************************************************************** CreateFork _$CreateForkFromJson(Map json) => CreateFork( - json['organization'] as String?, + organization: json['organization'] as String?, + name: json['name'] as String?, ); Map _$CreateForkToJson(CreateFork instance) => { 'organization': instance.organization, + 'name': instance.name, }; From 7e93cc91374e47f0c1b8c1b85ca4429dc3184b86 Mon Sep 17 00:00:00 2001 From: Ian Koerich Maciel Date: Tue, 25 Oct 2022 09:15:45 -0300 Subject: [PATCH 3/7] Update editRepository according to current documentation Current Github docs specify most of the parameters as optional. This commit update the existing editRepository method to these specs. https://docs.github.com/en/rest/repos/repos#update-a-repository --- lib/src/common/repos_service.dart | 41 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/src/common/repos_service.dart b/lib/src/common/repos_service.dart index 6fcc149b..6729f92c 100644 --- a/lib/src/common/repos_service.dart +++ b/lib/src/common/repos_service.dart @@ -168,29 +168,34 @@ class RepositoriesService extends Service { /// Edit a Repository. /// - /// API docs: https://developer.github.com/v3/repos/#edit - Future editRepository(RepositorySlug slug, - {String? name, - String? description, - String? homepage, - bool? private, - bool? hasIssues, - bool? hasWiki, - bool? hasDownloads}) async { + /// API docs: https://docs.github.com/en/rest/repos/repos#update-a-repository + Future editRepository( + RepositorySlug slug, { + String? name, + String? description, + String? homepage, + bool? private, + bool? hasIssues, + bool? hasWiki, + bool? hasDownloads, + String? defaultBranch, + }) async { ArgumentError.checkNotNull(slug); + final data = createNonNullMap({ - 'name': name!, - 'description': description!, - 'homepage': homepage!, - 'private': private!, - 'has_issues': hasIssues!, - 'has_wiki': hasWiki!, - 'has_downloads': hasDownloads!, - 'default_branch': 'defaultBranch' + 'name': name, + 'description': description, + 'homepage': homepage, + 'private': private, + 'has_issues': hasIssues, + 'has_wiki': hasWiki, + 'has_downloads': hasDownloads, + 'default_branch': defaultBranch, }); - return github.postJSON( + return github.postJSON, Repository>( '/repos/${slug.fullName}', body: GitHubJson.encode(data), + convert: (i) => Repository.fromJson(i), statusCode: 200, ); } From 50e44fbf1f2d7e3725e58c03b9406733d1d95abe Mon Sep 17 00:00:00 2001 From: Ian Koerich Maciel Date: Tue, 25 Oct 2022 09:17:56 -0300 Subject: [PATCH 4/7] Update existing addColaborator to meet Github specs Update the existing method addCollaborator to meet the current docs. https://docs.github.com/en/rest/collaborators/collaborators#add-a-repository-collaborator Instead of NO_CONTENT, the expected status code is CREATED. --- lib/src/common/repos_service.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/common/repos_service.dart b/lib/src/common/repos_service.dart index 6729f92c..997cb167 100644 --- a/lib/src/common/repos_service.dart +++ b/lib/src/common/repos_service.dart @@ -329,6 +329,7 @@ class RepositoriesService extends Service { return false; } + /// https://docs.github.com/en/rest/collaborators/collaborators#add-a-repository-collaborator Future addCollaborator(RepositorySlug slug, String user) async { ArgumentError.checkNotNull(slug); ArgumentError.checkNotNull(user); @@ -336,9 +337,9 @@ class RepositoriesService extends Service { .request( 'PUT', '/repos/${slug.fullName}/collaborators/$user', - statusCode: StatusCodes.NO_CONTENT, + statusCode: StatusCodes.CREATED, ) - .then((response) => response.statusCode == StatusCodes.NO_CONTENT); + .then((response) => response.statusCode == StatusCodes.CREATED); } Future removeCollaborator(RepositorySlug slug, String user) async { From d9c13bc96676e13603d47b5e799d2ea26c1e0960 Mon Sep 17 00:00:00 2001 From: Ian Koerich Maciel Date: Tue, 25 Oct 2022 09:21:15 -0300 Subject: [PATCH 5/7] Update generated mocks --- test/src/mocks.mocks.dart | 562 +++++++++++++++++++++++++++----------- 1 file changed, 405 insertions(+), 157 deletions(-) diff --git a/test/src/mocks.mocks.dart b/test/src/mocks.mocks.dart index 6b9c20c5..56e777d3 100644 --- a/test/src/mocks.mocks.dart +++ b/test/src/mocks.mocks.dart @@ -1,58 +1,180 @@ -// Mocks generated by Mockito 5.0.17 from annotations +// Mocks generated by Mockito 5.3.2 from annotations // in github/test/src/mocks.dart. // Do not manually edit this file. +// ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i4; import 'package:github/src/common.dart' as _i3; import 'package:http/http.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; +// ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters -// ignore_for_file: camel_case_types // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors -// ignore_for_file: unnecessary_overrides // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class -class _FakeClient_0 extends _i1.Fake implements _i2.Client {} +class _FakeClient_0 extends _i1.SmartFake implements _i2.Client { + _FakeClient_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeActivityService_1 extends _i1.Fake implements _i3.ActivityService {} +class _FakeActivityService_1 extends _i1.SmartFake + implements _i3.ActivityService { + _FakeActivityService_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeAuthorizationsService_2 extends _i1.Fake - implements _i3.AuthorizationsService {} +class _FakeAuthorizationsService_2 extends _i1.SmartFake + implements _i3.AuthorizationsService { + _FakeAuthorizationsService_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeGistsService_3 extends _i1.Fake implements _i3.GistsService {} +class _FakeGistsService_3 extends _i1.SmartFake implements _i3.GistsService { + _FakeGistsService_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeGitService_4 extends _i1.Fake implements _i3.GitService {} +class _FakeGitService_4 extends _i1.SmartFake implements _i3.GitService { + _FakeGitService_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeIssuesService_5 extends _i1.Fake implements _i3.IssuesService {} +class _FakeIssuesService_5 extends _i1.SmartFake implements _i3.IssuesService { + _FakeIssuesService_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeMiscService_6 extends _i1.Fake implements _i3.MiscService {} +class _FakeMiscService_6 extends _i1.SmartFake implements _i3.MiscService { + _FakeMiscService_6( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeOrganizationsService_7 extends _i1.Fake - implements _i3.OrganizationsService {} +class _FakeOrganizationsService_7 extends _i1.SmartFake + implements _i3.OrganizationsService { + _FakeOrganizationsService_7( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakePullRequestsService_8 extends _i1.Fake - implements _i3.PullRequestsService {} +class _FakePullRequestsService_8 extends _i1.SmartFake + implements _i3.PullRequestsService { + _FakePullRequestsService_8( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeRepositoriesService_9 extends _i1.Fake - implements _i3.RepositoriesService {} +class _FakeRepositoriesService_9 extends _i1.SmartFake + implements _i3.RepositoriesService { + _FakeRepositoriesService_9( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeSearchService_10 extends _i1.Fake implements _i3.SearchService {} +class _FakeSearchService_10 extends _i1.SmartFake implements _i3.SearchService { + _FakeSearchService_10( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeUrlShortenerService_11 extends _i1.Fake - implements _i3.UrlShortenerService {} +class _FakeUrlShortenerService_11 extends _i1.SmartFake + implements _i3.UrlShortenerService { + _FakeUrlShortenerService_11( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeUsersService_12 extends _i1.Fake implements _i3.UsersService {} +class _FakeUsersService_12 extends _i1.SmartFake implements _i3.UsersService { + _FakeUsersService_12( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeChecksService_13 extends _i1.Fake implements _i3.ChecksService {} +class _FakeChecksService_13 extends _i1.SmartFake implements _i3.ChecksService { + _FakeChecksService_13( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeResponse_14 extends _i1.Fake implements _i2.Response {} +class _FakeResponse_14 extends _i1.SmartFake implements _i2.Response { + _FakeResponse_14( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} /// A class which mocks [GitHub]. /// @@ -63,201 +185,327 @@ class MockGitHub extends _i1.Mock implements _i3.GitHub { } @override - set auth(_i3.Authentication? _auth) => - super.noSuchMethod(Invocation.setter(#auth, _auth), - returnValueForMissingStub: null); + set auth(_i3.Authentication? _auth) => super.noSuchMethod( + Invocation.setter( + #auth, + _auth, + ), + returnValueForMissingStub: null, + ); @override - String get endpoint => - (super.noSuchMethod(Invocation.getter(#endpoint), returnValue: '') - as String); + String get endpoint => (super.noSuchMethod( + Invocation.getter(#endpoint), + returnValue: '', + ) as String); @override - _i2.Client get client => (super.noSuchMethod(Invocation.getter(#client), - returnValue: _FakeClient_0()) as _i2.Client); + _i2.Client get client => (super.noSuchMethod( + Invocation.getter(#client), + returnValue: _FakeClient_0( + this, + Invocation.getter(#client), + ), + ) as _i2.Client); @override - _i3.ActivityService get activity => - (super.noSuchMethod(Invocation.getter(#activity), - returnValue: _FakeActivityService_1()) as _i3.ActivityService); + _i3.ActivityService get activity => (super.noSuchMethod( + Invocation.getter(#activity), + returnValue: _FakeActivityService_1( + this, + Invocation.getter(#activity), + ), + ) as _i3.ActivityService); @override - _i3.AuthorizationsService get authorizations => - (super.noSuchMethod(Invocation.getter(#authorizations), - returnValue: _FakeAuthorizationsService_2()) - as _i3.AuthorizationsService); + _i3.AuthorizationsService get authorizations => (super.noSuchMethod( + Invocation.getter(#authorizations), + returnValue: _FakeAuthorizationsService_2( + this, + Invocation.getter(#authorizations), + ), + ) as _i3.AuthorizationsService); @override - _i3.GistsService get gists => (super.noSuchMethod(Invocation.getter(#gists), - returnValue: _FakeGistsService_3()) as _i3.GistsService); + _i3.GistsService get gists => (super.noSuchMethod( + Invocation.getter(#gists), + returnValue: _FakeGistsService_3( + this, + Invocation.getter(#gists), + ), + ) as _i3.GistsService); @override - _i3.GitService get git => (super.noSuchMethod(Invocation.getter(#git), - returnValue: _FakeGitService_4()) as _i3.GitService); + _i3.GitService get git => (super.noSuchMethod( + Invocation.getter(#git), + returnValue: _FakeGitService_4( + this, + Invocation.getter(#git), + ), + ) as _i3.GitService); @override - _i3.IssuesService get issues => - (super.noSuchMethod(Invocation.getter(#issues), - returnValue: _FakeIssuesService_5()) as _i3.IssuesService); + _i3.IssuesService get issues => (super.noSuchMethod( + Invocation.getter(#issues), + returnValue: _FakeIssuesService_5( + this, + Invocation.getter(#issues), + ), + ) as _i3.IssuesService); @override - _i3.MiscService get misc => (super.noSuchMethod(Invocation.getter(#misc), - returnValue: _FakeMiscService_6()) as _i3.MiscService); + _i3.MiscService get misc => (super.noSuchMethod( + Invocation.getter(#misc), + returnValue: _FakeMiscService_6( + this, + Invocation.getter(#misc), + ), + ) as _i3.MiscService); @override _i3.OrganizationsService get organizations => (super.noSuchMethod( - Invocation.getter(#organizations), - returnValue: _FakeOrganizationsService_7()) as _i3.OrganizationsService); + Invocation.getter(#organizations), + returnValue: _FakeOrganizationsService_7( + this, + Invocation.getter(#organizations), + ), + ) as _i3.OrganizationsService); @override _i3.PullRequestsService get pullRequests => (super.noSuchMethod( - Invocation.getter(#pullRequests), - returnValue: _FakePullRequestsService_8()) as _i3.PullRequestsService); + Invocation.getter(#pullRequests), + returnValue: _FakePullRequestsService_8( + this, + Invocation.getter(#pullRequests), + ), + ) as _i3.PullRequestsService); @override _i3.RepositoriesService get repositories => (super.noSuchMethod( - Invocation.getter(#repositories), - returnValue: _FakeRepositoriesService_9()) as _i3.RepositoriesService); + Invocation.getter(#repositories), + returnValue: _FakeRepositoriesService_9( + this, + Invocation.getter(#repositories), + ), + ) as _i3.RepositoriesService); @override - _i3.SearchService get search => - (super.noSuchMethod(Invocation.getter(#search), - returnValue: _FakeSearchService_10()) as _i3.SearchService); + _i3.SearchService get search => (super.noSuchMethod( + Invocation.getter(#search), + returnValue: _FakeSearchService_10( + this, + Invocation.getter(#search), + ), + ) as _i3.SearchService); @override _i3.UrlShortenerService get urlShortener => (super.noSuchMethod( - Invocation.getter(#urlShortener), - returnValue: _FakeUrlShortenerService_11()) as _i3.UrlShortenerService); + Invocation.getter(#urlShortener), + returnValue: _FakeUrlShortenerService_11( + this, + Invocation.getter(#urlShortener), + ), + ) as _i3.UrlShortenerService); @override - _i3.UsersService get users => (super.noSuchMethod(Invocation.getter(#users), - returnValue: _FakeUsersService_12()) as _i3.UsersService); + _i3.UsersService get users => (super.noSuchMethod( + Invocation.getter(#users), + returnValue: _FakeUsersService_12( + this, + Invocation.getter(#users), + ), + ) as _i3.UsersService); @override - _i3.ChecksService get checks => - (super.noSuchMethod(Invocation.getter(#checks), - returnValue: _FakeChecksService_13()) as _i3.ChecksService); + _i3.ChecksService get checks => (super.noSuchMethod( + Invocation.getter(#checks), + returnValue: _FakeChecksService_13( + this, + Invocation.getter(#checks), + ), + ) as _i3.ChecksService); @override - _i4.Future getJSON(String? path, - {int? statusCode, - void Function(_i2.Response)? fail, - Map? headers, - Map? params, - _i3.JSONConverter? convert, - String? preview}) => + _i4.Future getJSON( + String? path, { + int? statusCode, + void Function(_i2.Response)? fail, + Map? headers, + Map? params, + _i3.JSONConverter? convert, + String? preview, + }) => (super.noSuchMethod( - Invocation.method(#getJSON, [ - path - ], { + Invocation.method( + #getJSON, + [path], + { #statusCode: statusCode, #fail: fail, #headers: headers, #params: params, #convert: convert, - #preview: preview - }), - returnValue: Future.value(null)) as _i4.Future); + #preview: preview, + }, + ), + returnValue: _i4.Future.value(null), + ) as _i4.Future); @override - _i4.Future postJSON(String? path, - {int? statusCode, - void Function(_i2.Response)? fail, - Map? headers, - Map? params, - _i3.JSONConverter? convert, - dynamic body, - String? preview}) => + _i4.Future postJSON( + String? path, { + int? statusCode, + void Function(_i2.Response)? fail, + Map? headers, + Map? params, + _i3.JSONConverter? convert, + dynamic body, + String? preview, + }) => (super.noSuchMethod( - Invocation.method(#postJSON, [ - path - ], { + Invocation.method( + #postJSON, + [path], + { #statusCode: statusCode, #fail: fail, #headers: headers, #params: params, #convert: convert, #body: body, - #preview: preview - }), - returnValue: Future.value(null)) as _i4.Future); + #preview: preview, + }, + ), + returnValue: _i4.Future.value(null), + ) as _i4.Future); @override - _i4.Future putJSON(String? path, - {int? statusCode, - void Function(_i2.Response)? fail, - Map? headers, - Map? params, - _i3.JSONConverter? convert, - dynamic body, - String? preview}) => + _i4.Future putJSON( + String? path, { + int? statusCode, + void Function(_i2.Response)? fail, + Map? headers, + Map? params, + _i3.JSONConverter? convert, + dynamic body, + String? preview, + }) => (super.noSuchMethod( - Invocation.method(#putJSON, [ - path - ], { + Invocation.method( + #putJSON, + [path], + { #statusCode: statusCode, #fail: fail, #headers: headers, #params: params, #convert: convert, #body: body, - #preview: preview - }), - returnValue: Future.value(null)) as _i4.Future); + #preview: preview, + }, + ), + returnValue: _i4.Future.value(null), + ) as _i4.Future); @override - _i4.Future patchJSON(String? path, - {int? statusCode, - void Function(_i2.Response)? fail, - Map? headers, - Map? params, - _i3.JSONConverter? convert, - dynamic body, - String? preview}) => + _i4.Future patchJSON( + String? path, { + int? statusCode, + void Function(_i2.Response)? fail, + Map? headers, + Map? params, + _i3.JSONConverter? convert, + dynamic body, + String? preview, + }) => (super.noSuchMethod( - Invocation.method(#patchJSON, [ - path - ], { + Invocation.method( + #patchJSON, + [path], + { #statusCode: statusCode, #fail: fail, #headers: headers, #params: params, #convert: convert, #body: body, - #preview: preview - }), - returnValue: Future.value(null)) as _i4.Future); + #preview: preview, + }, + ), + returnValue: _i4.Future.value(null), + ) as _i4.Future); @override - _i4.Future requestJson(String? method, String? path, - {int? statusCode, - void Function(_i2.Response)? fail, - Map? headers, - Map? params, - _i3.JSONConverter? convert, - dynamic body, - String? preview}) => + _i4.Future requestJson( + String? method, + String? path, { + int? statusCode, + void Function(_i2.Response)? fail, + Map? headers, + Map? params, + _i3.JSONConverter? convert, + dynamic body, + String? preview, + }) => (super.noSuchMethod( - Invocation.method(#requestJson, [ + Invocation.method( + #requestJson, + [ method, - path - ], { + path, + ], + { #statusCode: statusCode, #fail: fail, #headers: headers, #params: params, #convert: convert, #body: body, - #preview: preview - }), - returnValue: Future.value(null)) as _i4.Future); + #preview: preview, + }, + ), + returnValue: _i4.Future.value(null), + ) as _i4.Future); @override - _i4.Future<_i2.Response> request(String? method, String? path, - {Map? headers, - Map? params, - dynamic body, - int? statusCode, - void Function(_i2.Response)? fail, - String? preview}) => + _i4.Future<_i2.Response> request( + String? method, + String? path, { + Map? headers, + Map? params, + dynamic body, + int? statusCode, + void Function(_i2.Response)? fail, + String? preview, + }) => (super.noSuchMethod( - Invocation.method(#request, [ - method, - path - ], { - #headers: headers, - #params: params, - #body: body, - #statusCode: statusCode, - #fail: fail, - #preview: preview - }), - returnValue: Future<_i2.Response>.value(_FakeResponse_14())) - as _i4.Future<_i2.Response>); + Invocation.method( + #request, + [ + method, + path, + ], + { + #headers: headers, + #params: params, + #body: body, + #statusCode: statusCode, + #fail: fail, + #preview: preview, + }, + ), + returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_14( + this, + Invocation.method( + #request, + [ + method, + path, + ], + { + #headers: headers, + #params: params, + #body: body, + #statusCode: statusCode, + #fail: fail, + #preview: preview, + }, + ), + )), + ) as _i4.Future<_i2.Response>); @override - void handleStatusCode(_i2.Response? response) => - super.noSuchMethod(Invocation.method(#handleStatusCode, [response]), - returnValueForMissingStub: null); + void handleStatusCode(_i2.Response? response) => super.noSuchMethod( + Invocation.method( + #handleStatusCode, + [response], + ), + returnValueForMissingStub: null, + ); @override - void dispose() => super.noSuchMethod(Invocation.method(#dispose, []), - returnValueForMissingStub: null); + void dispose() => super.noSuchMethod( + Invocation.method( + #dispose, + [], + ), + returnValueForMissingStub: null, + ); } From b6352e7112049a8bad4fb67337b8cf03d69b3b09 Mon Sep 17 00:00:00 2001 From: Ian Koerich Maciel Date: Thu, 9 Feb 2023 10:52:35 -0300 Subject: [PATCH 6/7] Acept no content as an answer from add clb Co-authored-by: Rob Becker --- lib/src/common/repos_service.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/common/repos_service.dart b/lib/src/common/repos_service.dart index 997cb167..6a011e56 100644 --- a/lib/src/common/repos_service.dart +++ b/lib/src/common/repos_service.dart @@ -339,7 +339,7 @@ class RepositoriesService extends Service { '/repos/${slug.fullName}/collaborators/$user', statusCode: StatusCodes.CREATED, ) - .then((response) => response.statusCode == StatusCodes.CREATED); + .then((response) => response.statusCode == StatusCodes.CREATED || response.statusCode == StatusCodes. NO_CONTENT); } Future removeCollaborator(RepositorySlug slug, String user) async { From 9ca7b88f1bce7acd42aaf4998e89f0ea6c9c8eaf Mon Sep 17 00:00:00 2001 From: Ian Koerich Maciel Date: Thu, 9 Feb 2023 10:53:32 -0300 Subject: [PATCH 7/7] Remove expected status code from add clb request Co-authored-by: Rob Becker --- lib/src/common/repos_service.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/common/repos_service.dart b/lib/src/common/repos_service.dart index 6a011e56..dd8012c0 100644 --- a/lib/src/common/repos_service.dart +++ b/lib/src/common/repos_service.dart @@ -337,7 +337,6 @@ class RepositoriesService extends Service { .request( 'PUT', '/repos/${slug.fullName}/collaborators/$user', - statusCode: StatusCodes.CREATED, ) .then((response) => response.statusCode == StatusCodes.CREATED || response.statusCode == StatusCodes. NO_CONTENT); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy