Skip to content

Commit

Permalink
Add membership and functionality to other services (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanato12 authored Feb 13, 2024
1 parent 196678f commit fdc8cd2
Show file tree
Hide file tree
Showing 262 changed files with 2,767 additions and 203 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
run: cargo login ${{ secrets.CARGO_TOKEN }}

- name: publish
run: cargo publish
run: make publish
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"core/lib/",
"core/line_liff",
"core/line_manage_audience",
"core/line_membership",
"core/line_messaging_api",
"core/line_module",
"core/line_module_attach",
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: publish
publish:
cargo publish --manifest-path core/lib/Cargo.toml
10 changes: 7 additions & 3 deletions core/lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "line-bot-sdk-rust"
version = "1.0.0"
version = "1.0.1"
authors = ["nanato12 <admin@okj.info>"]
edition = "2021"
description = "LINE Messaging API SDK for Rust"
Expand Down Expand Up @@ -48,8 +48,12 @@ path = "../line_liff"
version = "0.0.1"
path = "../line_manage_audience"

[dependencies.line_messaging_api]
[dependencies.line_membership]
version = "0.0.1"
path = "../line_membership"

[dependencies.line_messaging_api]
version = "0.0.2"
path = "../line_messaging_api"

[dependencies.line_module]
Expand All @@ -65,5 +69,5 @@ version = "0.0.1"
path = "../line_shop"

[dependencies.line_webhook]
version = "1.0.0"
version = "1.0.1"
path = "../line_webhook"
10 changes: 10 additions & 0 deletions core/lib/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ use line_liff::apis::{configuration::Configuration as LiffConfiguration, LiffApi
use line_manage_audience::apis::{
configuration::Configuration as ManageAudienceConfiguration, ManageAudienceApiClient,
};
use line_membership::apis::{
configuration::Configuration as MembershipConfiguration, MembershipApiClient,
};
use line_messaging_api::apis::{
configuration::Configuration as MessagingApiConfiguration, MessagingApiApiClient,
};
Expand All @@ -48,6 +51,7 @@ pub struct LINE {
pub insight_api_client: InsightApiClient<C>,
pub liff_api_client: LiffApiClient<C>,
pub manage_audience_api_client: ManageAudienceApiClient<C>,
pub membership_api_client: MembershipApiClient<C>,
pub messaging_api_client: MessagingApiApiClient<C>,
pub module_api_client: LineModuleApiClient<C>,
pub module_attach_api_client: LineModuleAttachApiClient<C>,
Expand Down Expand Up @@ -82,6 +86,11 @@ impl LINE {
let manage_audience_api_client =
ManageAudienceApiClient::new(Rc::new(manage_audience_conf));

// membership
let mut membership_conf = MembershipConfiguration::new(client.clone());
membership_conf.oauth_access_token = Some(token.to_owned());
let membership_api_client = MembershipApiClient::new(Rc::new(membership_conf));

// messaging_api
let mut messaging_api_conf = MessagingApiConfiguration::new(client.clone());
messaging_api_conf.oauth_access_token = Some(token.to_owned());
Expand Down Expand Up @@ -112,6 +121,7 @@ impl LINE {
insight_api_client,
liff_api_client,
manage_audience_api_client,
membership_api_client,
messaging_api_client,
module_api_client,
module_attach_api_client,
Expand Down
20 changes: 20 additions & 0 deletions core/line_membership/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "line_membership"
version = "0.0.1"
authors = ["OpenAPI Generator team and contributors"]
description = "This document describes LINE Official Account Membership API."
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
edition = "2018"

[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde", "v4"] }
hyper = { version = "~0.14", features = ["full"] }
hyper-tls = "~0.5"
http = "~0.2"
base64 = "~0.7.0"
futures = "^0.3"
52 changes: 52 additions & 0 deletions core/line_membership/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Rust API client for line_membership

This document describes LINE Official Account Membership API.


## Overview

This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.

- API version: 0.0.1
- Package version: 0.0.1
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`

## Installation

Put the package under your project folder in a directory named `line_membership` and add the following to `Cargo.toml` under `[dependencies]`:

```
line_membership = { path = "./line_membership" }
```

## Documentation for API Endpoints

All URIs are relative to *https://api.line.me*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*MembershipApi* | [**get_membership_list**](docs/MembershipApi.md#get_membership_list) | **Get** /membership/v1/list |
*MembershipApi* | [**get_membership_subscription**](docs/MembershipApi.md#get_membership_subscription) | **Get** /membership/v1/subscription/{userId} |


## Documentation For Models

- [ErrorResponse](docs/ErrorResponse.md)
- [GetMembershipSubscriptionResponse](docs/GetMembershipSubscriptionResponse.md)
- [Membership](docs/Membership.md)
- [MembershipListResponse](docs/MembershipListResponse.md)
- [MembershipMeta](docs/MembershipMeta.md)
- [MembershipUser](docs/MembershipUser.md)
- [Subscription](docs/Subscription.md)


To get access to the crate's generated documentation, use:

```
cargo doc --open
```

## Author



12 changes: 12 additions & 0 deletions core/line_membership/docs/ErrorResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ErrorResponse

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**message** | **String** | Error message |
**details** | Option<**Vec<String>**> | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


11 changes: 11 additions & 0 deletions core/line_membership/docs/GetMembershipSubscriptionResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# GetMembershipSubscriptionResponse

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**subscriptions** | [**Vec<crate::models::Subscription>**](Subscription.md) | List of subscription information |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


20 changes: 20 additions & 0 deletions core/line_membership/docs/Membership.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Membership

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**membership_id** | **i32** | Membership plan ID. |
**title** | **String** | Membership plan name. |
**description** | **String** | Membership plan description. |
**benefits** | **Vec<String>** | List of membership plan perks. |
**price** | **f64** | Monthly fee for membership plan. (e.g. 1500.00) |
**currency** | **String** | The currency of membership.price. |
**member_count** | **i32** | Number of members subscribed to the membership plan. |
**member_limit** | Option<**i32**> | The upper limit of members who can subscribe. If no upper limit is set, it will be null. |
**is_in_app_purchase** | **bool** | Payment method for users who subscribe to a membership plan. |
**is_published** | **bool** | Membership plan status. |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


67 changes: 67 additions & 0 deletions core/line_membership/docs/MembershipApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# \MembershipApi

All URIs are relative to *https://api.line.me*

Method | HTTP request | Description
------------- | ------------- | -------------
[**get_membership_list**](MembershipApi.md#get_membership_list) | **Get** /membership/v1/list |
[**get_membership_subscription**](MembershipApi.md#get_membership_subscription) | **Get** /membership/v1/subscription/{userId} |



## get_membership_list

> crate::models::MembershipListResponse get_membership_list()

Get a list of memberships.

### Parameters

This endpoint does not need any parameter.

### Return type

[**crate::models::MembershipListResponse**](MembershipListResponse.md)

### Authorization

[Bearer](../README.md#Bearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)


## get_membership_subscription

> crate::models::GetMembershipSubscriptionResponse get_membership_subscription(user_id)

Get a user's membership subscription.

### Parameters


Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**user_id** | **String** | User ID | [required] |

### Return type

[**crate::models::GetMembershipSubscriptionResponse**](GetMembershipSubscriptionResponse.md)

### Authorization

[Bearer](../README.md#Bearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

11 changes: 11 additions & 0 deletions core/line_membership/docs/MembershipListResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# MembershipListResponse

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**memberships** | [**Vec<crate::models::Membership>**](Membership.md) | List of membership information |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


16 changes: 16 additions & 0 deletions core/line_membership/docs/MembershipMeta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# MembershipMeta

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**membership_id** | **i32** | Membership plan ID. |
**title** | **String** | Membership plan name. |
**description** | **String** | Membership plan description. |
**benefits** | **Vec<String>** | List of membership plan perks. |
**price** | **f64** | Monthly fee for membership plan. (e.g. 1500.00) |
**currency** | **String** | The currency of membership.price. |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


14 changes: 14 additions & 0 deletions core/line_membership/docs/MembershipUser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# MembershipUser

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**membership_no** | **i32** | The user's member number in the membership plan. |
**joined_time** | **i32** | UNIX timestamp at which the user subscribed to the membership. |
**next_billing_date** | **String** | Next payment date for membership plan. - Format: yyyy-MM-dd (e.g. 2024-02-08) - Timezone: UTC+9 |
**total_subscription_months** | **i32** | The period of time in months that the user has been subscribed to a membership plan. If a user previously canceled and then re-subscribed to the same membership plan, only the period after the re-subscription will be counted. |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


12 changes: 12 additions & 0 deletions core/line_membership/docs/Subscription.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Subscription

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**membership** | [**crate::models::MembershipMeta**](MembershipMeta.md) | |
**user** | [**crate::models::MembershipUser**](MembershipUser.md) | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


41 changes: 41 additions & 0 deletions core/line_membership/src/apis/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2016 LINE Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

use std::rc::Rc;

use super::configuration::Configuration;
use hyper;

pub struct APIClient {
membership_api: Box<dyn crate::apis::MembershipApi>,
}

impl APIClient {
pub fn new<C: hyper::client::connect::Connect>(configuration: Configuration<C>) -> APIClient
where
C: Clone + std::marker::Send + Sync + 'static,
{
let rc = Rc::new(configuration);

APIClient {
membership_api: Box::new(crate::apis::MembershipApiClient::new(rc.clone())),
}
}

pub fn membership_api(&self) -> &dyn crate::apis::MembershipApi {
self.membership_api.as_ref()
}
}
Loading

0 comments on commit fdc8cd2

Please sign in to comment.