Skip to content

Commit f706ec6

Browse files
authored
feat: customer groups and segments (#107)
1 parent 867a6a1 commit f706ec6

26 files changed

+936
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 2.1.0 October 14th, 2023
2+
- Added customer group and customer segment endpoints!
3+
14
### 2.0.2 October 14th, 2023
25
- Hot fixed issue with modifier location overrides
36

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import 'package:equatable/equatable.dart';
2+
import 'package:json_annotation/json_annotation.dart';
3+
import 'package:square_connect/square_connect.dart';
4+
5+
part 'create_customer_group.g.dart';
6+
7+
@JsonSerializable()
8+
class CreateCustomerGroupRequest extends Equatable {
9+
const CreateCustomerGroupRequest({
10+
this.group,
11+
this.idempotencyKey,
12+
});
13+
14+
/// Converts a [Map] to an [CreateCustomerGroupRequest]
15+
factory CreateCustomerGroupRequest.fromJson(Map<String, dynamic> json) =>
16+
_$CreateCustomerGroupRequestFromJson(json);
17+
18+
/// Converts a [CreateCustomerGroupRequest] to a [Map]
19+
Map<String, dynamic> toJson() => _$CreateCustomerGroupRequestToJson(this);
20+
21+
/// The idempotency key for the request.
22+
final String? idempotencyKey;
23+
24+
/// The customer group to create.
25+
final CustomerGroup? group;
26+
27+
@override
28+
List<Object?> get props => [idempotencyKey, group];
29+
}
30+
31+
@JsonSerializable()
32+
class CreateCustomerGroupResponse extends SquareResponse {
33+
const CreateCustomerGroupResponse({this.group, super.errors});
34+
35+
/// Converts a [Map] to an [CreateCustomerGroupResponse]
36+
factory CreateCustomerGroupResponse.fromJson(Map<String, dynamic> json) =>
37+
_$CreateCustomerGroupResponseFromJson(json);
38+
39+
/// Converts a [CreateCustomerGroupResponse] to a [Map]
40+
Map<String, dynamic> toJson() => _$CreateCustomerGroupResponseToJson(this);
41+
42+
/// The successfully created customer group.
43+
final CustomerGroup? group;
44+
45+
@override
46+
List<Object?> get props => [group, errors];
47+
}

lib/src/functions_model/create_customer_group.g.dart

+57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/functions_model/create_payment_link.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CreatePaymentLinkRequest extends Equatable {
3939
order,
4040
checkoutOptions,
4141
prePopulatedData,
42-
paymentNote
42+
paymentNote,
4343
];
4444
}
4545

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import 'package:json_annotation/json_annotation.dart';
2+
import 'package:square_connect/square_connect.dart';
3+
4+
part 'delete_customer_group.g.dart';
5+
6+
@JsonSerializable()
7+
class DeleteCustomerGroupResponse extends SquareResponse {
8+
const DeleteCustomerGroupResponse({super.errors});
9+
10+
/// Converts a [Map] to an [DeleteCustomerGroupResponse]
11+
factory DeleteCustomerGroupResponse.fromJson(Map<String, dynamic> json) =>
12+
_$DeleteCustomerGroupResponseFromJson(json);
13+
14+
/// Converts a [DeleteCustomerGroupResponse] to a [Map]
15+
Map<String, dynamic> toJson() => _$DeleteCustomerGroupResponseToJson(this);
16+
17+
@override
18+
List<Object?> get props => [errors];
19+
}

lib/src/functions_model/delete_customer_group.g.dart

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/functions_model/functions_model.dart

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export 'clone_order.dart';
1010
export 'create_card.dart';
1111
export 'create_checkout.dart';
1212
export 'create_customer.dart';
13+
export 'create_customer_group.dart';
1314
export 'create_gift_card.dart';
1415
export 'create_gift_card_activity.dart';
1516
export 'create_invoice.dart';
@@ -21,6 +22,7 @@ export 'create_payment.dart';
2122
export 'create_payment_link.dart';
2223
export 'create_subscription.dart';
2324
export 'delete_customer.dart';
25+
export 'delete_customer_group.dart';
2426
export 'delete_invoice.dart';
2527
export 'delete_loyalty_reward.dart';
2628
export 'delete_subscription_action.dart';
@@ -29,6 +31,8 @@ export 'get_invoice.dart';
2931
export 'link_customer_to_gift_card.dart';
3032
export 'list_cards.dart';
3133
export 'list_catalog.dart';
34+
export 'list_customer_groups.dart';
35+
export 'list_customer_segments.dart';
3236
export 'list_customers.dart';
3337
export 'list_gift_cards.dart';
3438
export 'list_invoices.dart';
@@ -45,6 +49,8 @@ export 'resume_subscription.dart';
4549
export 'retrieve_card.dart';
4650
export 'retrieve_catalog_objects.dart';
4751
export 'retrieve_customer.dart';
52+
export 'retrieve_customer_group.dart';
53+
export 'retrieve_customer_segment.dart';
4854
export 'retrieve_gift_card.dart';
4955
export 'retrieve_gift_card_from_gan.dart';
5056
export 'retrieve_gift_card_from_nonce.dart';
@@ -67,6 +73,7 @@ export 'search_subscriptions.dart';
6773
export 'swap_plan.dart';
6874
export 'unlink_customer_from_gift_card.dart';
6975
export 'update_customer.dart';
76+
export 'update_customer_group.dart';
7077
export 'update_invoice.dart';
7178
export 'update_location.dart';
7279
export 'update_order.dart';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import 'package:json_annotation/json_annotation.dart';
2+
import 'package:square_connect/square_connect.dart';
3+
4+
part 'list_customer_groups.g.dart';
5+
6+
@JsonSerializable()
7+
class ListCustomerGroupsResponse extends SquareResponse {
8+
const ListCustomerGroupsResponse({
9+
this.groups,
10+
this.cursor,
11+
super.errors,
12+
});
13+
14+
/// Converts a [Map] to an [ListCustomerGroupsResponse]
15+
factory ListCustomerGroupsResponse.fromJson(Map<String, dynamic> json) =>
16+
_$ListCustomerGroupsResponseFromJson(json);
17+
18+
/// Converts a [ListCustomerGroupsResponse] to a [Map]
19+
Map<String, dynamic> toJson() => _$ListCustomerGroupsResponseToJson(this);
20+
21+
/// A list of customer groups belonging to the current seller.
22+
final List<CustomerGroup>? groups;
23+
24+
/// A pagination cursor to retrieve the next set of results for your
25+
/// original query to the endpoint. This value is present only if the
26+
/// request succeeded and additional results are available.
27+
final String? cursor;
28+
29+
@override
30+
List<Object?> get props => [groups, cursor, errors];
31+
}

lib/src/functions_model/list_customer_groups.g.dart

+35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import 'package:json_annotation/json_annotation.dart';
2+
import 'package:square_connect/square_connect.dart';
3+
4+
part 'list_customer_segments.g.dart';
5+
6+
@JsonSerializable()
7+
class ListCustomerSegmentsResponse extends SquareResponse {
8+
const ListCustomerSegmentsResponse({
9+
this.segments,
10+
this.cursor,
11+
super.errors,
12+
});
13+
14+
/// Converts a [Map] to an [ListCustomerSegmentsResponse]
15+
factory ListCustomerSegmentsResponse.fromJson(Map<String, dynamic> json) =>
16+
_$ListCustomerSegmentsResponseFromJson(json);
17+
18+
/// Converts a [ListCustomerSegmentsResponse] to a [Map]
19+
Map<String, dynamic> toJson() => _$ListCustomerSegmentsResponseToJson(this);
20+
21+
/// The list of customer segments belonging to the associated Square account.
22+
final List<CustomerSegment>? segments;
23+
24+
/// A pagination cursor to be used in subsequent calls to
25+
/// ListCustomerSegments to retrieve the next set of query results. The cursor
26+
/// is only present if the request succeeded and additional results are
27+
/// available.
28+
final String? cursor;
29+
30+
@override
31+
List<Object?> get props => [segments, cursor, errors];
32+
}

lib/src/functions_model/list_customer_segments.g.dart

+35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:json_annotation/json_annotation.dart';
2+
import 'package:square_connect/square_connect.dart';
3+
4+
part 'retrieve_customer_group.g.dart';
5+
6+
@JsonSerializable()
7+
class RetrieveCustomerGroupResponse extends SquareResponse {
8+
const RetrieveCustomerGroupResponse({this.group, super.errors});
9+
10+
/// Converts a [Map] to an [RetrieveCustomerGroupResponse]
11+
factory RetrieveCustomerGroupResponse.fromJson(Map<String, dynamic> json) =>
12+
_$RetrieveCustomerGroupResponseFromJson(json);
13+
14+
/// Converts a [RetrieveCustomerGroupResponse] to a [Map]
15+
Map<String, dynamic> toJson() => _$RetrieveCustomerGroupResponseToJson(this);
16+
17+
final CustomerGroup? group;
18+
19+
@override
20+
List<Object?> get props => [group, errors];
21+
}

0 commit comments

Comments
 (0)