-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Your Name
committed
Oct 15, 2022
1 parent
925adf7
commit 023d866
Showing
7 changed files
with
439 additions
and
0 deletions.
There are no files selected for viewing
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,8 @@ | ||
# Files and directories created by pub. | ||
.dart_tool/ | ||
.packages | ||
|
||
# Conventional directory for build output. | ||
build/ | ||
|
||
bin/ |
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,3 @@ | ||
## 1.0.0 | ||
|
||
- Initial version. |
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,30 @@ | ||
# This file configures the static analysis results for your project (errors, | ||
# warnings, and lints). | ||
# | ||
# This enables the 'recommended' set of lints from `package:lints`. | ||
# This set helps identify many issues that may lead to problems when running | ||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | ||
# style and format. | ||
# | ||
# If you want a smaller set of lints you can change this to specify | ||
# 'package:lints/core.yaml'. These are just the most critical lints | ||
# (the recommended set includes the core lints). | ||
# The core lints are also what is used by pub.dev for scoring packages. | ||
|
||
include: package:lints/recommended.yaml | ||
|
||
# Uncomment the following section to specify additional rules. | ||
|
||
# linter: | ||
# rules: | ||
# - camel_case_types | ||
|
||
# analyzer: | ||
# exclude: | ||
# - path/to/excluded/files/** | ||
|
||
# For more information about the core and recommended set of lints, see | ||
# https://dart.dev/go/core-lints | ||
|
||
# For additional information about configuring this file, see | ||
# https://dart.dev/guides/language/analysis-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps | ||
|
||
library oy; | ||
|
||
import 'dart:convert'; | ||
|
||
import 'package:http/http.dart'; | ||
|
||
enum OyEnvironmentType { live, sandbox } | ||
|
||
class Oy { | ||
late String url_api_sandbox = "https://api-stg.oyindonesia.com"; | ||
late String url_api_live = "https://partner.oyindonesia.com"; | ||
late OyEnvironmentType oy_environment_type; | ||
Oy({ | ||
OyEnvironmentType oyEnvironmentType = OyEnvironmentType.sandbox, | ||
}) { | ||
oy_environment_type = oyEnvironmentType; | ||
} | ||
Future<Response> invoke({ | ||
required String method, | ||
required String username, | ||
required String api_key, | ||
Map? parameter, | ||
OyEnvironmentType? oyEnvironmentType, | ||
}) async { | ||
oyEnvironmentType ??= oy_environment_type; | ||
String url_api = url_api_sandbox; | ||
if (oyEnvironmentType == OyEnvironmentType.live) { | ||
url_api = url_api_live; | ||
} | ||
late Map<String, String> headers = { | ||
'Content-Type': 'application/json', | ||
'x-oy-username': username, | ||
'x-api-key': api_key, | ||
}; | ||
Uri url = Uri.parse("${url_api}${method}"); | ||
return await post(url, headers: headers, body: json.encode(parameter)); | ||
} | ||
} |
Oops, something went wrong.