Giter Site home page Giter Site logo

afdian-sdk's Introduction

afdian - 爱发电 SDK for Node.js & Browser

GitHub followers npm npm npm Travis (.com) Code Climate maintainability Code Climate coverage

使用 Usage

安装 Install

yarn add afdian
# or
npm install --save afdian

引入 Import

import Afdian, { AfdianClientOptions, AfdianSponsorResponse, AfdianOrderResponse } from 'afdian';
// 其中 { } 中 ts 类型可以不导入
// Types in { } block can be ignored

const afdian = new Afdian({
  userId: 'xxxx',
  token: 'xxxx'
});
// Ref: https://afdian.net/dashboard/dev

const res = await afdian.ping();
// {
//   ec: 200,
//   em: 'pong',
//   data: { }
// }

// 查询订单
const res = await afdian.queryOrder(1);
// {
//   ec: 200,
//   em: 'order',
//   data: {
//     list: [],
//     total_count: 0,
//     total_page: 0
//   }
// }

// 查询赞助者
const res = await afdian.querySponsor(1);
// {
//   ec: 200,
//   em: 'sponsor',
//   data: {
//     list: [],
//     total_count: 0,
//     total_page: 0
//   }
// }

// 订单 Webhook 回调
const res = await afdian.webhookOrder(context);
// {
//   "ec": 200,
//   "em": "ok",
//   "data": {
//     "type": "order",
//     "order": {
//       "out_trade_no": "202106232138371083454010626",
//       "user_id": "adf397fe8374811eaacee52540025c377",
//       "plan_id": "a45353328af911eb973052540025c377",
//       "month": 1,
//       "total_amount": "5.00",
//       "show_amount": "5.00",
//       "status": 2,
//       "remark": "",
//       "redeem_id": "",
//       "product_type": 0,
//       "discount": "0.00",
//       "sku_detail": [],
//       "address_person": "",
//       "address_phone": "",
//       "address_address": ""
//     }
//   }
// }

License

Apache 2.0

捐赠 / Donate: https://afdian.net/@willin

afdian-sdk's People

Contributors

willin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.