这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
44ce699
docs(README): update readme
ryanaidilp Sep 15, 2023
daedbf8
refactor(exceptions): update exception class
ryanaidilp Sep 15, 2023
00d1bb2
refactor(repository): remove dead code
ryanaidilp Sep 15, 2023
da497dd
test(models): update test name
ryanaidilp Sep 15, 2023
796d2a2
test(models): add missing test for domain and publication model
ryanaidilp Sep 15, 2023
12d6ff8
refactor(endpoint): update infographic endpoint name and add endpoint
ryanaidilp Sep 15, 2023
d9251d6
refactor(datasource): rename endpoint
ryanaidilp Sep 15, 2023
89196d2
test(endpoint): add test for static table endpoint
ryanaidilp Sep 15, 2023
5521a3e
feat(entity): create static table entity
ryanaidilp Sep 15, 2023
9af562a
feat(repository): create static table repository contradt
ryanaidilp Sep 15, 2023
837ceef
feat(usecase): create use case for static table
ryanaidilp Sep 15, 2023
f9223f2
feat(models): add static table model
ryanaidilp Sep 15, 2023
b99bdd0
refactor(import): optimize code import
ryanaidilp Sep 15, 2023
07e3a79
refactor(export): optimize file export
ryanaidilp Sep 15, 2023
a271f56
feat(exceptions): add exception and failure for static table
ryanaidilp Sep 15, 2023
e5ad68b
feat(serializer): create table serializer
ryanaidilp Sep 15, 2023
e14450d
feat(models): create static table model
ryanaidilp Sep 15, 2023
6057805
feat(datasource): create static table remote data source
ryanaidilp Sep 15, 2023
493f45c
feat(repository): create static table repository implementation
ryanaidilp Sep 15, 2023
15af0f6
feat(static_table): add static table to list and view
ryanaidilp Sep 15, 2023
1614e65
feat(build_runner): re-build
ryanaidilp Sep 15, 2023
c526bf8
feat(example): add preview for static table feature
ryanaidilp Sep 15, 2023
7e22252
refactor(entity): update static table property docs
ryanaidilp Sep 15, 2023
4d0a310
docs(README): update readme
ryanaidilp Sep 15, 2023
977615b
test(fixtures): add fixture for static table
ryanaidilp Sep 15, 2023
69a8024
test(static_table): add static table test in list and view
ryanaidilp Sep 15, 2023
f31c7be
test(usecase): create unit test for static table use case
ryanaidilp Sep 15, 2023
0a7d3c3
test(datasource): static table remote data source test
ryanaidilp Sep 15, 2023
f570f09
test(repository): add unit test for static table repository impl
ryanaidilp Sep 15, 2023
b1b0847
test(unit_test): add teardown all to all unit test
ryanaidilp Sep 15, 2023
5436a3a
refactor(repository): remove dead code
ryanaidilp Sep 15, 2023
17538ea
Merge pull request #17 from ryanaidilp/feature/static-table
ryanaidilp Sep 15, 2023
c92fffe
chore(version): bump version number
ryanaidilp Sep 15, 2023
75e3ef7
docs(changelog): update changelog
ryanaidilp Sep 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,50 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.4.0+10

> 2023-09-15

### What's New?

#### Fetch Static Table Data from BPS API (PR [#17](https://github.com/ryanaidilp/stadata_flutter_sdk/pull/17))

- Added support for fetching static table data from the BPS (Bureau of Public Statistics) API.
- Introduced a new `StaticTable` class to model static table data.
- Implemented API requests and data parsing logic for retrieving static tables.
- Documented the usage of the new feature in the SDK's documentation.

#### Documentation Updates

- Updated README to reflect the new Static Table feature (PR [#17](https://github.com/ryanaidilp/stadata_flutter_sdk/pull/17)).

### Refactor

#### Codebase Improvements (PR [#17](https://github.com/ryanaidilp/stadata_flutter_sdk/pull/17))

- Refactored exception classes.
- Removed dead code from the repository.
- Updated test names and added missing tests for domain and publication models (PR #128).
- Renamed infographic endpoint and added a new endpoint.
- Added tests for the static table endpoint.
- Created the `StaticTable` entity, repository contract, use case, and model.
- Optimized code import and file export.
- Added exceptions and failures for the static table feature (PR #138).
- Created a table serializer.
- Added tests for the static table model, remote data source, and repository implementation.
- Integrated the static table feature into list and view.
- Added an example preview for the static table feature.
- Updated static table property documentation.
- Added fixtures and tests for static tables.
- Implemented unit tests for the static table use case and repository.
- Added teardown steps to all unit tests.

### Chore

#### Dependency Updates

- Updated project dependencies to the latest versions.

## 0.3.5+9

> 2023-09-15
Expand Down
157 changes: 140 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![ci](https://github.com/ryanaidilp/stadata_flutter_sdk/actions/workflows/main.yaml/badge.svg)](https://github.com/ryanaidilp/stadata_flutter_sdk/actions/workflows/main.yaml)
[![Code Coverage](https://github.com/ryanaidilp/stadata_flutter_sdk/actions/workflows/coverage.yaml/badge.svg)](https://github.com/ryanaidilp/stadata_flutter_sdk/actions/workflows/coverage.yaml)
[![codecov](https://codecov.io/gh/ryanaidilp/stadata_flutter_sdk/graph/badge.svg?token=UERSUEG6MD)](https://codecov.io/gh/ryanaidilp/stadata_flutter_sdk)
![Website](https://img.shields.io/website?up_message=Up&up_color=green&down_message=Down&down_color=red&url=https%3A%2F%2Fwebapi.bps.go.id&logo=serverfault&label=https%3A%2F%2Fwebapi.bps.go.id&link=https%3A%2F%2Fwebapi.bps.go.id)
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason)
[![License: MIT][license_badge]][license_link]
Expand All @@ -20,7 +21,7 @@

## Description

The **STADATA Flutter SDK** is a powerful and user-friendly Flutter SDK designed to seamlessly integrate with the official API offered by the Badan Pusat Statistik (BPS) Statistic of the Republic of Indonesia. BPS offers a [WebAPI](https://webapi.bps.go.id/developer/) - <https://webapi.bps.go.id/developer/> that allows users to programmatically access various types of data, including Publications, Press Releases, static tables, and dynamic tables.
The **STADATA Flutter SDK** is a powerful and user-friendly Flutter SDK designed to seamlessly integrate with the official API offered by the Badan Pusat Statistik (BPS) Statistic of the Republic of Indonesia. BPS offers a [WebAPI](https://webapi.bps.go.id/developer/) - <https://webapi.bps.go.id/developer/> that allows users to programmatically access various types of data, including Publications, Press Releases, Static Tables, Dynamic Tables, and many more.

This SDK empowers Flutter developers to effortlessly access a wealth of statistical data and information directly from BPS's extensive database, enabling the creation of data-driven applications that provide valuable insights into various aspects of Indonesia's socio-economic landscape.

Expand Down Expand Up @@ -64,10 +65,16 @@ For detailed usage instructions and documentation of the BPS API, please refer t
- [Infographics](#infographics)
- [Parameters](#parameters-2)
- [Properties (Infographic)](#properties-infographic)
- [Static Tables](#static-tables)
- [Parameters](#parameters-3)
- [Properties (StaticTable)](#properties-statictable)
- [View API](#view-api)
- [Publication Detail](#publication-detail)
- [Parameters](#parameters-3)
- [Parameters](#parameters-4)
- [Properties (Publication)](#properties-publication-1)
- [Static Table Detail](#static-table-detail)
- [Parameters](#parameters-5)
- [Properties (StaticTable)](#properties-statictable-1)
- [To-Do](#to-do)
- [List API TODO](#list-api-todo)
- [View API TODO](#view-api-todo)
Expand Down Expand Up @@ -106,7 +113,7 @@ Follow these steps to quickly integrate the Stadata Flutter SDK into your Flutte

- **Initialize the SDK:**

Initialize the Stadata Flutter SDK in your `main.dart` file and make sure to include your API token. Replace `'YOUR_API_KEY'` with your actual API key obtained from the Stadata API.
Initialize the Stadata Flutter SDK in your `main.dart` file and make sure to include your API token. Replace `'YOUR_API_KEY'` with your actual API key obtained from the [Web API BPS](https://webapi.bps.go.id/developer).

```dart
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -460,6 +467,74 @@ for (final infographic in infographicList) {
| `category` | `String` | The category or topic to which the infographic belongs. |
| `downloadUrl` | `String` | The URL from which the infographic can be downloaded. |

### Static Tables

This method is used to retrieve a list of static tables based on the selected domain (region).

#### Parameters

| Parameter | Type | Description |
| --------- | -------------- | ---------------------------------------------------------------- |
| `domain` | `String` | The domain (region) code for retrieving static tables. |
| `lang` | `DataLanguage` | The language for static table data (default: `DataLanguage.id`). |
| `page` | `int` | The page number (default: `1`). |
| `keyword` | `String?` | A keyword for searching static tables (optional). |
| `month` | `int?` | The month for filtering static tables (optional - `1..12`). |
| `year` | `int?` | The year for filtering static tables (optional). |

Example usage and sample output:

```dart
// Fetch static table data from BPS API
final staticTableResult = await StadataFlutter.instance.list.staticTable(
domain: 'example_domain_code', // Replace with the desired domain code
lang: DataLanguage.id,
page: 1,
keyword: 'example_keyword', // Replace with desired keyword or null
month: null, // Replace with desired month or null
year: null, // Replace with desired year or null
);

final staticTableList = staticTableResult.data;
final pagination = staticTableResult.pagination;

// Print pagination info
print('Current Page: ${pagination.page}');
print('Total Pages: ${pagination.pages}');
print('Data Count in This Page: ${pagination.count}');
print('Per Page: ${pagination.perPage}');
print('Total: ${pagination.total}');
print('------------------------');

// Print the retrieved static table data
for (final staticTable in staticTableList) {
print('Table ID: ${staticTable.id}');
print('Table Title: ${staticTable.title}');
print('Subject ID: ${staticTable.subjectId}');
print('Subject: ${staticTable.subject}');
print('Size: ${staticTable.size}');
print('Table: ${staticTable.table}');
print('Updated At: ${staticTable.updatedAt}');
print('Created At: ${staticTable.createdAt}');
print('Excel Link: ${staticTable.excel}');
}

```

#### Properties (StaticTable)

| Property | Type | Description |
| ----------- | ----------- | --------------------------------------------------------------- |
| `id` | `int` | The unique identifier of the table. |
| `title` | `String` | The title or name of the table. |
| `subjectId` | `int` | The optional subject identifier associated with the table. |
| `subject` | `String?` | The optional subject name or description. |
| `size` | `String` | The file size. |
| `table` | `String?` | The HTML representation of the table. |
| `updatedAt` | `DateTime` | The date and time when the table was last updated. |
| `createdAt` | `DateTime?` | The optional date and time when the table was created. |
| `excel` | `String` | A link or reference to the associated Excel file for the table. |

You can use these methods and properties to retrieve and work with data resources from the BPS API.

---
Expand Down Expand Up @@ -496,18 +571,18 @@ final publication = await StadataFlutter.instance.view.publication(
lang: DataLanguage.id,
);

print('Publication ID: ${publication.id}');
print('Title: ${publication.title}');
print('ISSN: ${publication.issn}');
print('Scheduled Date: ${publication.scheduledDate}');
print('Release Date: ${publication.releaseDate}');
print('Update Date: ${publication.updateDate}');
print('Cover Image URL: ${publication.cover}');
print('PDF File URL: ${publication.pdf}');
print('Size: ${publication.size}');
print('Abstract: ${publication.abstract ?? 'Not available'}');
print('Catalogue Number: ${publication.catalogueNumber ?? 'Not available'}');
print('Publication Number: ${publication.publicationNumber ?? 'Not available'}');
print('Publication ID: ${publication.id}');
print('Title: ${publication.title}');
print('ISSN: ${publication.issn}');
print('Scheduled Date: ${publication.scheduledDate}');
print('Release Date: ${publication.releaseDate}');
print('Update Date: ${publication.updateDate}');
print('Cover Image URL: ${publication.cover}');
print('PDF File URL: ${publication.pdf}');
print('Size: ${publication.size}');
print('Abstract: ${publication.abstract ?? 'Not available'}');
print('Catalogue Number: ${publication.catalogueNumber ?? 'Not available'}');
print('Publication Number: ${publication.publicationNumber ?? 'Not available'}');
```

#### Properties (Publication)
Expand All @@ -527,6 +602,54 @@ final publication = await StadataFlutter.instance.view.publication(
| `catalogueNumber` | `String?` | An optional catalogue number associated with the publication (optional). |
| `publicationNumber` | `String?` | An optional publication number or code (optional). |

### Static Table Detail

This method is used to retrieve detailed information about a specific publication.

#### Parameters

| Parameter | Type | Description |
| --------- | -------------- | ---------------------------------------------------------------- |
| `id` | `String` | The unique identifier of the static table. |
| `domain` | `String` | The domain (region) code for retrieving static table detail. |
| `lang` | `DataLanguage` | The language for static table data (default: `DataLanguage.id`). |

Example usage and sample output:

```dart
// Fetch static table detail from BPS API
final staticTable = await StadataFlutter.instance.view.staticTable(
id: 'example_static_table_id', // Replace with the desired static table ID
domain: 'example_domain', // Replace with the desired Domain Code
lang: DataLanguage.id,
);


print('Table ID: ${staticTable.id}');
print('Table Title: ${staticTable.title}');
print('Subject ID: ${staticTable.subjectId}');
print('Subject: ${staticTable.subject}');
print('Size: ${staticTable.size}');
print('Table: ${staticTable.table}');
print('Updated At: ${staticTable.updatedAt}');
print('Created At: ${staticTable.createdAt}');
print('Excel Link: ${staticTable.excel}');
```

#### Properties (StaticTable)

| Property | Type | Description |
| ----------- | ----------- | --------------------------------------------------------------- |
| `id` | `int` | The unique identifier of the table. |
| `title` | `String` | The title or name of the table. |
| `subjectId` | `int` | The optional subject identifier associated with the table. |
| `subject` | `String?` | The optional subject name or description. |
| `size` | `String` | The file size. |
| `table` | `String?` | The HTML representation of the table. |
| `updatedAt` | `DateTime` | The date and time when the table was last updated. |
| `createdAt` | `DateTime?` | The optional date and time when the table was created. |
| `excel` | `String` | A link or reference to the associated Excel file for the table. |

---

## To-Do
Expand All @@ -536,7 +659,7 @@ final publication = await StadataFlutter.instance.view.publication(
- ✅ Domains
- ✅ Publications
- ✅ Infographics
- 🔄 Static Table
- Static Table
- 🔄 Dynamic Table
- 🔄 Press Release
- 🔄 News
Expand All @@ -545,7 +668,7 @@ final publication = await StadataFlutter.instance.view.publication(
### View API TODO

- ✅ Publication
- 🔄 Static Table
- Static Table
- 🔄 Dynamic Table
- 🔄 Press Release
- 🔄 News
Expand Down
1 change: 1 addition & 0 deletions example/lib/app/modules/home/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class HomeView extends GetView<HomeController> {
const _Button('Domains', Routes.DOMAIN),
const _Button('Infographics', Routes.INFOGRAPHIC),
const _Button('Publications', Routes.PUBLICATION),
const _Button('Static Tables', Routes.STATIC_TABLE),
],
),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:get/get.dart';

import '../controllers/static_table_controller.dart';

class StaticTableBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<StaticTableController>(
() => StaticTableController(),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:stadata_flutter_sdk/stadata_flutter_sdk.dart';

class StaticTableController extends GetxController
with StateMixin<ListResult<StaticTable>> {
final selectedLang = Rx(DataLanguage.id);
final domain = Rx<String>('7200');
final keyword = Rxn<String>();
final page = Rx<String>('1');
final date = Rxn<DateTime>();
final TextEditingController dateCtl = TextEditingController();

@override
void onInit() {
loadStaticTables();
super.onInit();
}

Future loadStaticTables() async {
try {
change(null, status: RxStatus.loading());
final result = await StadataFlutter.instance.list.staticTables(
domain: domain.value,
lang: selectedLang.value,
keyword: keyword.value,
page: int.parse(page.value),
year: date.value != null ? date.value!.year : null,
month: date.value != null ? date.value!.month : null,
);

if (result.data.isEmpty) {
change(null, status: RxStatus.empty());
} else {
change(result, status: RxStatus.success());
}
} catch (e) {
change(null, status: RxStatus.error(e.toString()));
}
}

@override
void onClose() {
dateCtl.dispose();
super.onClose();
}
}
Loading