Advertisement
Guest User

Untitled

a guest
Apr 4th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.60 KB | None | 0 0
  1. import 'package:http/http.dart' as http;
  2. import 'dart:convert';
  3.  
  4. Future<UserList> postFromJson(String secret, String status) async{
  5. print('ini statusnya : ');
  6. print(status);
  7. http.Response response = await http.get("http://128.199.85.63:3000/api/v1/transactions/adm?key=3577c7bf7dsa7232dsadsd123-670f2eb21c4__&secret=$secret&status='$status'");
  8.  
  9. final jsonData = json.decode(response.body);
  10. return UserList.fromJson(jsonData);
  11.  
  12.  
  13. }
  14.  
  15. class UserList {
  16. int status;
  17. List<Results> results;
  18.  
  19. UserList({this.status, this.results});
  20.  
  21. UserList.fromJson(Map<String, dynamic> json) {
  22. try{
  23. status = json['status'];
  24. if (json['results'] != null) {
  25. results = new List<Results>();
  26. json['results'].forEach((v) {
  27. results.add(new Results.fromJson(v));
  28. });
  29. }
  30. }catch(e, err){
  31. print(err.toString());
  32. }
  33. }
  34.  
  35. Map<String, dynamic> toJson() {
  36. final Map<String, dynamic> data = new Map<String, dynamic>();
  37. data['status'] = this.status;
  38. if (this.results != null) {
  39. data['results'] = this.results.map((v) => v.toJson()).toList();
  40. }
  41. return data;
  42. }
  43. }
  44.  
  45. class Results {
  46. int id;
  47. int userId;
  48. int courierId;
  49. int invoiceNo;
  50. String trxNo;
  51. int totalPrice;
  52. int grandTotal;
  53. String discount;
  54. int discountAmmount;
  55. String paymentGateway;
  56. String paymentMethod;
  57. int trxTimestamp;
  58. String trxStatus;
  59. int bankId;
  60. String trxDatetime;
  61. String token;
  62. String voucherCode;
  63. String note;
  64. String resiNo;
  65. String deliveryPrice;
  66. Bank bank;
  67. User user;
  68. Address address;
  69. List<Items> items;
  70. Courier courier;
  71.  
  72. Results(
  73. {this.id,
  74. this.userId,
  75. this.courierId,
  76. this.invoiceNo,
  77. this.trxNo,
  78. this.totalPrice,
  79. this.grandTotal,
  80. this.discount,
  81. this.discountAmmount,
  82. this.paymentGateway,
  83. this.paymentMethod,
  84. this.trxTimestamp,
  85. this.trxStatus,
  86. this.bankId,
  87. this.trxDatetime,
  88. this.token,
  89. this.voucherCode,
  90. this.note,
  91. this.resiNo,
  92. this.deliveryPrice,
  93. this.bank,
  94. this.user,
  95. this.address,
  96. this.items,
  97. this.courier});
  98.  
  99. Results.fromJson(Map<String, dynamic> json) {
  100. id = json['id'];
  101. userId = json['user_id'];
  102. courierId = json['courier_id'];
  103. invoiceNo = json['invoice_no'];
  104. trxNo = json['trx_no'];
  105. totalPrice = json['total_price'];
  106. grandTotal = json['grand_total'];
  107. discount = json['discount'];
  108. discountAmmount = json['discount_ammount'];
  109. paymentGateway = json['payment_gateway'];
  110. paymentMethod = json['payment_method'];
  111. trxTimestamp = json['trx_timestamp'];
  112. trxStatus = json['trx_status'];
  113. bankId = json['bank_id'];
  114. trxDatetime = json['trx_datetime'];
  115. token = json['token'];
  116. voucherCode = json['voucher_code'];
  117. note = json['note'];
  118. resiNo = json['resi_no'];
  119. deliveryPrice = json['delivery_price'];
  120. bank = json['bank'] != null ? new Bank.fromJson(json['bank']) : null;
  121. user = json['user'] != null ? new User.fromJson(json['user']) : null;
  122. address =
  123. json['address'] != null ? new Address.fromJson(json['address']) : null;
  124. if (json['items'] != null) {
  125. items = new List<Items>();
  126. json['items'].forEach((v) {
  127. items.add(new Items.fromJson(v));
  128. });
  129. }
  130. courier =
  131. json['courier'] != null ? new Courier.fromJson(json['courier']) : null;
  132. }
  133.  
  134. Map<String, dynamic> toJson() {
  135. final Map<String, dynamic> data = new Map<String, dynamic>();
  136. data['id'] = this.id;
  137. data['user_id'] = this.userId;
  138. data['courier_id'] = this.courierId;
  139. data['invoice_no'] = this.invoiceNo;
  140. data['trx_no'] = this.trxNo;
  141. data['total_price'] = this.totalPrice;
  142. data['grand_total'] = this.grandTotal;
  143. data['discount'] = this.discount;
  144. data['discount_ammount'] = this.discountAmmount;
  145. data['payment_gateway'] = this.paymentGateway;
  146. data['payment_method'] = this.paymentMethod;
  147. data['trx_timestamp'] = this.trxTimestamp;
  148. data['trx_status'] = this.trxStatus;
  149. data['bank_id'] = this.bankId;
  150. data['trx_datetime'] = this.trxDatetime;
  151. data['token'] = this.token;
  152. data['voucher_code'] = this.voucherCode;
  153. data['note'] = this.note;
  154. data['resi_no'] = this.resiNo;
  155. data['delivery_price'] = this.deliveryPrice;
  156. if (this.bank != null) {
  157. data['bank'] = this.bank.toJson();
  158. }
  159. if (this.user != null) {
  160. data['user'] = this.user.toJson();
  161. }
  162. if (this.address != null) {
  163. data['address'] = this.address.toJson();
  164. }
  165. if (this.items != null) {
  166. data['items'] = this.items.map((v) => v.toJson()).toList();
  167. }
  168. if (this.courier != null) {
  169. data['courier'] = this.courier.toJson();
  170. }
  171. return data;
  172. }
  173. }
  174.  
  175. class Bank {
  176. int id;
  177. String namaBank;
  178. String noRek;
  179. String namaPemilikRek;
  180. String icon;
  181. String sofId;
  182.  
  183. Bank(
  184. {this.id,
  185. this.namaBank,
  186. this.noRek,
  187. this.namaPemilikRek,
  188. this.icon,
  189. this.sofId});
  190.  
  191. Bank.fromJson(Map<String, dynamic> json) {
  192. id = json['id'];
  193. namaBank = json['nama_bank'];
  194. noRek = json['no_rek'];
  195. namaPemilikRek = json['nama_pemilik_rek'];
  196. icon = json['icon'];
  197. sofId = json['sof_id'];
  198. }
  199.  
  200. Map<String, dynamic> toJson() {
  201. final Map<String, dynamic> data = new Map<String, dynamic>();
  202. data['id'] = this.id;
  203. data['nama_bank'] = this.namaBank;
  204. data['no_rek'] = this.noRek;
  205. data['nama_pemilik_rek'] = this.namaPemilikRek;
  206. data['icon'] = this.icon;
  207. data['sof_id'] = this.sofId;
  208. return data;
  209. }
  210. }
  211.  
  212. class User {
  213. int id;
  214. String username;
  215. String email;
  216. String fullName;
  217. dynamic firstName;
  218. dynamic lastName;
  219. String profilePictureOriginal;
  220. String profilePictureBlured;
  221. String profilePictureThumb;
  222. String profilePictureSmall;
  223. String profilePictureMedium;
  224. dynamic registredTimestamp;
  225. int lastLoginTimestamp;
  226. String lastLoginIp;
  227. dynamic emailVerified;
  228. String password;
  229. int isAdmin;
  230. String phone;
  231. String smId;
  232. String smType;
  233. dynamic fcmToken;
  234. dynamic verifyToken;
  235. int role;
  236. dynamic forgotCode;
  237. int lastUsedCourier;
  238.  
  239. User(
  240. {this.id,
  241. this.username,
  242. this.email,
  243. this.fullName,
  244. this.firstName,
  245. this.lastName,
  246. this.profilePictureOriginal,
  247. this.profilePictureBlured,
  248. this.profilePictureThumb,
  249. this.profilePictureSmall,
  250. this.profilePictureMedium,
  251. this.registredTimestamp,
  252. this.lastLoginTimestamp,
  253. this.lastLoginIp,
  254. this.emailVerified,
  255. this.password,
  256. this.isAdmin,
  257. this.phone,
  258. this.smId,
  259. this.smType,
  260. this.fcmToken,
  261. this.verifyToken,
  262. this.role,
  263. this.forgotCode,
  264. this.lastUsedCourier});
  265.  
  266. User.fromJson(Map<String, dynamic> json) {
  267. id = json['id'];
  268. username = json['username'];
  269. email = json['email'];
  270. fullName = json['full_name'];
  271. firstName = json['first_name'];
  272. lastName = json['last_name'];
  273. profilePictureOriginal = json['profile_picture_original'];
  274. profilePictureBlured = json['profile_picture_blured'];
  275. profilePictureThumb = json['profile_picture_thumb'];
  276. profilePictureSmall = json['profile_picture_small'];
  277. profilePictureMedium = json['profile_picture_medium'];
  278. registredTimestamp = json['registred_timestamp'];
  279. lastLoginTimestamp = json['last_login_timestamp'];
  280. lastLoginIp = json['last_login_ip'];
  281. emailVerified = json['email_verified'];
  282. password = json['password'];
  283. isAdmin = json['is_admin'];
  284. phone = json['phone'];
  285. smId = json['sm_id'];
  286. smType = json['sm_type'];
  287. fcmToken = json['fcm_token'];
  288. verifyToken = json['verify_token'];
  289. role = json['role'];
  290. forgotCode = json['forgot_code'];
  291. lastUsedCourier = json['last_used_courier'];
  292. }
  293.  
  294. Map<String, dynamic> toJson() {
  295. final Map<String, dynamic> data = new Map<String, dynamic>();
  296. data['id'] = this.id;
  297. data['username'] = this.username;
  298. data['email'] = this.email;
  299. data['full_name'] = this.fullName;
  300. data['first_name'] = this.firstName;
  301. data['last_name'] = this.lastName;
  302. data['profile_picture_original'] = this.profilePictureOriginal;
  303. data['profile_picture_blured'] = this.profilePictureBlured;
  304. data['profile_picture_thumb'] = this.profilePictureThumb;
  305. data['profile_picture_small'] = this.profilePictureSmall;
  306. data['profile_picture_medium'] = this.profilePictureMedium;
  307. data['registred_timestamp'] = this.registredTimestamp;
  308. data['last_login_timestamp'] = this.lastLoginTimestamp;
  309. data['last_login_ip'] = this.lastLoginIp;
  310. data['email_verified'] = this.emailVerified;
  311. data['password'] = this.password;
  312. data['is_admin'] = this.isAdmin;
  313. data['phone'] = this.phone;
  314. data['sm_id'] = this.smId;
  315. data['sm_type'] = this.smType;
  316. data['fcm_token'] = this.fcmToken;
  317. data['verify_token'] = this.verifyToken;
  318. data['role'] = this.role;
  319. data['forgot_code'] = this.forgotCode;
  320. data['last_used_courier'] = this.lastUsedCourier;
  321. return data;
  322. }
  323. }
  324.  
  325. class Address {
  326. int id;
  327. int trxId;
  328. String fullName;
  329. String address;
  330. int provinceId;
  331. int cityId;
  332. int districtId;
  333. int posCode;
  334. String phoneNumber;
  335. Province province;
  336. City city;
  337.  
  338. Address(
  339. {this.id,
  340. this.trxId,
  341. this.fullName,
  342. this.address,
  343. this.provinceId,
  344. this.cityId,
  345. this.districtId,
  346. this.posCode,
  347. this.phoneNumber,
  348. this.province,
  349. this.city});
  350.  
  351. Address.fromJson(Map<String, dynamic> json) {
  352. id = json['id'];
  353. trxId = json['trx_id'];
  354. fullName = json['full_name'];
  355. address = json['address'];
  356. provinceId = json['province_id'];
  357. cityId = json['city_id'];
  358. districtId = json['district_id'];
  359. posCode = json['pos_code'];
  360. phoneNumber = json['phone_number'];
  361. province = json['province'] != null
  362. ? new Province.fromJson(json['province'])
  363. : null;
  364. city = json['city'] != null ? new City.fromJson(json['city']) : null;
  365. }
  366.  
  367. Map<String, dynamic> toJson() {
  368. final Map<String, dynamic> data = new Map<String, dynamic>();
  369. data['id'] = this.id;
  370. data['trx_id'] = this.trxId;
  371. data['full_name'] = this.fullName;
  372. data['address'] = this.address;
  373. data['province_id'] = this.provinceId;
  374. data['city_id'] = this.cityId;
  375. data['district_id'] = this.districtId;
  376. data['pos_code'] = this.posCode;
  377. data['phone_number'] = this.phoneNumber;
  378. if (this.province != null) {
  379. data['province'] = this.province.toJson();
  380. }
  381. if (this.city != null) {
  382. data['city'] = this.city.toJson();
  383. }
  384. return data;
  385. }
  386. }
  387.  
  388. class Province {
  389. int id;
  390. String name;
  391.  
  392. Province({this.id, this.name});
  393.  
  394. Province.fromJson(Map<String, dynamic> json) {
  395. id = json['id'];
  396. name = json['name'];
  397. }
  398.  
  399. Map<String, dynamic> toJson() {
  400. final Map<String, dynamic> data = new Map<String, dynamic>();
  401. data['id'] = this.id;
  402. data['name'] = this.name;
  403. return data;
  404. }
  405. }
  406.  
  407. class City {
  408. int id;
  409. int provinceId;
  410. String name;
  411.  
  412. City({this.id, this.provinceId, this.name});
  413.  
  414. City.fromJson(Map<String, dynamic> json) {
  415. id = json['id'];
  416. provinceId = json['province_id'];
  417. name = json['name'];
  418. }
  419.  
  420. Map<String, dynamic> toJson() {
  421. final Map<String, dynamic> data = new Map<String, dynamic>();
  422. data['id'] = this.id;
  423. data['province_id'] = this.provinceId;
  424. data['name'] = this.name;
  425. return data;
  426. }
  427. }
  428.  
  429. class Items {
  430. int id;
  431. int trxId;
  432. int productId;
  433. int qty;
  434. Product product;
  435.  
  436. Items({this.id, this.trxId, this.productId, this.qty, this.product});
  437.  
  438. Items.fromJson(Map<String, dynamic> json) {
  439. id = json['id'];
  440. trxId = json['trx_id'];
  441. productId = json['product_id'];
  442. qty = json['qty'];
  443. product =
  444. json['product'] != null ? new Product.fromJson(json['product']) : null;
  445. }
  446.  
  447. Map<String, dynamic> toJson() {
  448. final Map<String, dynamic> data = new Map<String, dynamic>();
  449. data['id'] = this.id;
  450. data['trx_id'] = this.trxId;
  451. data['product_id'] = this.productId;
  452. data['qty'] = this.qty;
  453. if (this.product != null) {
  454. data['product'] = this.product.toJson();
  455. }
  456. return data;
  457. }
  458. }
  459.  
  460. class Product {
  461. int id;
  462. String name;
  463. String descriptions;
  464. int category;
  465. dynamic createdTimestamp;
  466. dynamic lastEditedTimestamp;
  467. dynamic lastEditedBy;
  468. dynamic createdBy;
  469. dynamic orderNumber;
  470. String productCode;
  471. String discount;
  472. int freeDelivery;
  473. int stock;
  474. String tags;
  475. dynamic featuredImage;
  476. String unit;
  477. int minimumOrder;
  478. int price;
  479. int published;
  480. int featured;
  481. int unitSold;
  482. int weight;
  483. dynamic idPenjual;
  484. ImageData image;
  485.  
  486. Product(
  487. {this.id,
  488. this.name,
  489. this.descriptions,
  490. this.category,
  491. this.createdTimestamp,
  492. this.lastEditedTimestamp,
  493. this.lastEditedBy,
  494. this.createdBy,
  495. this.orderNumber,
  496. this.productCode,
  497. this.discount,
  498. this.freeDelivery,
  499. this.stock,
  500. this.tags,
  501. this.featuredImage,
  502. this.unit,
  503. this.minimumOrder,
  504. this.price,
  505. this.published,
  506. this.featured,
  507. this.unitSold,
  508. this.weight,
  509. this.idPenjual,
  510. this.image});
  511.  
  512. Product.fromJson(Map<String, dynamic> json) {
  513. id = json['id'];
  514. name = json['name'];
  515. descriptions = json['descriptions'];
  516. category = json['category'];
  517. createdTimestamp = json['created_timestamp'];
  518. lastEditedTimestamp = json['last_edited_timestamp'];
  519. lastEditedBy = json['last_edited_by'];
  520. createdBy = json['created_by'];
  521. orderNumber = json['order_number'];
  522. productCode = json['product_code'];
  523. discount = json['discount'];
  524. freeDelivery = json['free_delivery'];
  525. stock = json['stock'];
  526. tags = json['tags'];
  527. featuredImage = json['featured_image'];
  528. unit = json['unit'];
  529. minimumOrder = json['minimum_order'];
  530. price = json['price'];
  531. published = json['published'];
  532. featured = json['featured'];
  533. unitSold = json['unit_sold'];
  534. weight = json['weight'];
  535. idPenjual = json['id_penjual'];
  536. image = json['image'] != null ? new ImageData.fromJson(json['image']) : null;
  537. }
  538.  
  539. Map<String, dynamic> toJson() {
  540. final Map<String, dynamic> data = new Map<String, dynamic>();
  541. data['id'] = this.id;
  542. data['name'] = this.name;
  543. data['descriptions'] = this.descriptions;
  544. data['category'] = this.category;
  545. data['created_timestamp'] = this.createdTimestamp;
  546. data['last_edited_timestamp'] = this.lastEditedTimestamp;
  547. data['last_edited_by'] = this.lastEditedBy;
  548. data['created_by'] = this.createdBy;
  549. data['order_number'] = this.orderNumber;
  550. data['product_code'] = this.productCode;
  551. data['discount'] = this.discount;
  552. data['free_delivery'] = this.freeDelivery;
  553. data['stock'] = this.stock;
  554. data['tags'] = this.tags;
  555. data['featured_image'] = this.featuredImage;
  556. data['unit'] = this.unit;
  557. data['minimum_order'] = this.minimumOrder;
  558. data['price'] = this.price;
  559. data['published'] = this.published;
  560. data['featured'] = this.featured;
  561. data['unit_sold'] = this.unitSold;
  562. data['weight'] = this.weight;
  563. data['id_penjual'] = this.idPenjual;
  564. if (this.image != null) {
  565. data['image'] = this.image.toJson();
  566. }
  567. return data;
  568. }
  569. }
  570.  
  571. class ImageData {
  572. int id;
  573. int productId;
  574. String imageBig;
  575. String imageMedium;
  576. String imageSmall;
  577. String imageThumb;
  578. String imageBlured;
  579. String imageOriginal;
  580. int featured;
  581.  
  582. ImageData(
  583. {this.id,
  584. this.productId,
  585. this.imageBig,
  586. this.imageMedium,
  587. this.imageSmall,
  588. this.imageThumb,
  589. this.imageBlured,
  590. this.imageOriginal,
  591. this.featured});
  592.  
  593. ImageData.fromJson(Map<String, dynamic> json) {
  594. id = json['id'];
  595. productId = json['product_id'];
  596. imageBig = json['image_big'];
  597. imageMedium = json['image_medium'];
  598. imageSmall = json['image_small'];
  599. imageThumb = json['image_thumb'];
  600. imageBlured = json['image_blured'];
  601. imageOriginal = json['image_original'];
  602. featured = json['featured'];
  603. }
  604.  
  605. Map<String, dynamic> toJson() {
  606. final Map<String, dynamic> data = new Map<String, dynamic>();
  607. data['id'] = this.id;
  608. data['product_id'] = this.productId;
  609. data['image_big'] = this.imageBig;
  610. data['image_medium'] = this.imageMedium;
  611. data['image_small'] = this.imageSmall;
  612. data['image_thumb'] = this.imageThumb;
  613. data['image_blured'] = this.imageBlured;
  614. data['image_original'] = this.imageOriginal;
  615. data['featured'] = this.featured;
  616. return data;
  617. }
  618. }
  619.  
  620. class Courier {
  621. int id;
  622. String name;
  623. String descriptions;
  624. String icon;
  625. int coverageAll;
  626. int deliveryMin;
  627. int deliveryMax;
  628. String deliveryUnit;
  629. String priceType;
  630. int price;
  631. int weight;
  632. int addedTimestamp;
  633.  
  634. Courier(
  635. {this.id,
  636. this.name,
  637. this.descriptions,
  638. this.icon,
  639. this.coverageAll,
  640. this.deliveryMin,
  641. this.deliveryMax,
  642. this.deliveryUnit,
  643. this.priceType,
  644. this.price,
  645. this.weight,
  646. this.addedTimestamp});
  647.  
  648. Courier.fromJson(Map<String, dynamic> json) {
  649. id = json['id'];
  650. name = json['name'];
  651. descriptions = json['descriptions'];
  652. icon = json['icon'];
  653. coverageAll = json['coverage_all'];
  654. deliveryMin = json['delivery_min'];
  655. deliveryMax = json['delivery_max'];
  656. deliveryUnit = json['delivery_unit'];
  657. priceType = json['price_type'];
  658. price = json['price'];
  659. weight = json['weight'];
  660. addedTimestamp = json['added_timestamp'];
  661. }
  662.  
  663. Map<String, dynamic> toJson() {
  664. final Map<String, dynamic> data = new Map<String, dynamic>();
  665. data['id'] = this.id;
  666. data['name'] = this.name;
  667. data['descriptions'] = this.descriptions;
  668. data['icon'] = this.icon;
  669. data['coverage_all'] = this.coverageAll;
  670. data['delivery_min'] = this.deliveryMin;
  671. data['delivery_max'] = this.deliveryMax;
  672. data['delivery_unit'] = this.deliveryUnit;
  673. data['price_type'] = this.priceType;
  674. data['price'] = this.price;
  675. data['weight'] = this.weight;
  676. data['added_timestamp'] = this.addedTimestamp;
  677. return data;
  678. }
  679. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement