Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Oct 15, 2022
1 parent 925adf7 commit 023d866
Show file tree
Hide file tree
Showing 7 changed files with 439 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
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/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version.
30 changes: 30 additions & 0 deletions analysis_options.yaml
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
40 changes: 40 additions & 0 deletions lib/oy.dart
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));
}
}
Loading

0 comments on commit 023d866

Please sign in to comment.