Advertisement
Guest User

Untitled

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