vkdart

Форк
0
/
market_order.dart 
127 строк · 3.8 Кб
1
import 'package:vkdart/vkontakte.dart';
2

3
/// Market Order model.
4
///
5
/// See https://dev.vk.com/ru/reference/objects/market-order
6
class MarketOrderModel {
7
  /// Payload.
8
  final Map<String, dynamic> payload;
9

10
  // ignore: public_member_api_docs
11
  MarketOrderModel(this.payload);
12

13
  /// The order ID.
14
  int? get id => payload['id'];
15

16
  /// The community ID.
17
  int? get groupId => payload['group_id'];
18

19
  /// The buyer's ID.
20
  int? get userId => payload['user_id'];
21

22
  /// The date the order was created in Unixtime format.
23
  int? get createdAt => payload['date'];
24

25
  /// ID of the option group.
26
  int? get variantsGroupingId => payload['variants_grouping_id'];
27

28
  /// Whether the option is the main one.
29
  bool? get isMainVariant => payload['is_main_variant'];
30

31
  /// Variants.
32
  List<MarketOrderPropertyValuesModel>? get propertyValues =>
33
      (payload['property_values'] as List?)
34
          ?.map((e) => MarketOrderPropertyValuesModel(
35
              (e as Map).cast<String, dynamic>()))
36
          .toList();
37

38
  /// The quantity of the product in the cart.
39
  int? get cartQuantity => payload['cart_quantity'];
40

41
  /// Order status.
42
  int? get status => payload['status'];
43

44
  /// The number of items in the order.
45
  int? get itemsCount => payload['items_count'];
46

47
  /// The total cost of the order.
48
  Map<String, dynamic>? get totalPrice => payload['total_price'];
49

50
  /// the cost in hundredths of a unit of currency.
51
  int? get totalPriceAmount => totalPrice?['amount'];
52

53
  /// currency identifier
54
  int? get totalPriceCurrencyId => totalPrice?['currency']?['id'];
55

56
  /// currency designation;
57
  String? get totalPriceCurrencyName => totalPrice?['currency']?['name'];
58

59
  /// a string representation of the order value.
60
  String? get totalPriceText => totalPrice?['text'];
61

62
  /// The order number, consisting of the customer ID and the order ID.
63
  int? get displayOrderId => payload['display_order_id'];
64

65
  /// Comment on the order.
66
  String? get comment => payload['comment'];
67

68
  /// See https://dev.vk.com/ru/reference/objects/market-order#preview_order_items
69
  List<MarketAttachmentModel>? get previewOrderItems =>
70
      (payload['preview_order_items'] as List)
71
          .map((e) => MarketAttachmentModel((e as Map).cast<String, dynamic>()))
72
          .toList();
73

74
  /// Delivery information.
75
  ///
76
  /// See https://dev.vk.com/ru/reference/objects/market-order#delivery
77
  Map<String, dynamic>? get delivery => payload['delivery'];
78

79
  /// Delivery address.
80
  String? get deliveryAddress => delivery?['address'];
81

82
  /// Delivery type.
83
  String? get deliveryType => delivery?['type'];
84

85
  /// the track number for tracking the order.
86
  String? get deliveryTrackNumber => delivery?['track_number'];
87

88
  /// a link to track the order by track number.
89
  String? get deliveryTrackLink => delivery?['track_link'];
90

91
  /// information about the pick-up point.
92
  Object? get deliveryPoint => delivery?['delivery_point'];
93

94
  /// Information about the buyer.
95
  ///
96
  /// See https://dev.vk.com/ru/reference/objects/market-order#recipient
97
  Map<String, dynamic>? get recipient => payload['recipient'];
98

99
  /// the buyer's name.
100
  String? get recipientName => recipient?['name'];
101

102
  /// The buyer's number.
103
  String? get recipientPhone => recipient?['phone'];
104

105
  /// String representation of customer information.
106
  String? get recipientDisplayText => recipient?['display_text'];
107
}
108

109
/// Market Order Property Values model.
110
///
111
/// See https://dev.vk.com/ru/reference/objects/market-order#property_values
112
class MarketOrderPropertyValuesModel {
113
  // ignore: public_member_api_docs
114
  MarketOrderPropertyValuesModel(this.payload);
115

116
  /// Payload.
117
  final Map<String, dynamic> payload;
118

119
  /// Id variant.
120
  int get variantId => payload['variant_id'];
121

122
  /// Variant name.
123
  String get variantName => payload['variant_name'];
124

125
  /// Property name.
126
  String get propertyName => payload['property_name'];
127
}
128

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.