-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cd862f
commit 6c0c0e9
Showing
8 changed files
with
64 additions
and
36 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace PagBank | ||
{ | ||
public interface IPagBankConfig | ||
{ | ||
BaseUrl BaseUrl { get; } | ||
string Token { get; } | ||
IRestClient? RestClient { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace PagBank | ||
{ | ||
public class PagBankConfig : IPagBankConfig | ||
{ | ||
public required BaseUrl BaseUrl { get; set; } | ||
public required string Token { get; set; } | ||
public IRestClient? RestClient { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
global using PagBank.Extension; | ||
global using RestSharp; | ||
global using RestSharp.Authenticators.OAuth2; | ||
global using System.ComponentModel; | ||
global using System.Reflection; | ||
global using RestSharp.Authenticators.OAuth2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace PagBank | ||
{ | ||
public class PagBankUtil | ||
{ | ||
internal static string GetUserAgent() | ||
{ | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
var attribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>(); | ||
var version = attribute?.InformationalVersion; | ||
return $"pagbank-dotnet/{version}"; | ||
} | ||
|
||
internal static RestClientOptions RestClientOptions(PagBankConfig pagBankConfig) | ||
{ | ||
var options = new RestClientOptions(pagBankConfig.BaseUrl.GetDescription()); | ||
options.Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(pagBankConfig.Token, "Bearer"); | ||
return options; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters