Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: customer groups and segments #107

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 2.1.0 October 14th, 2023
- Added customer group and customer segment endpoints!

### 2.0.2 October 14th, 2023
- Hot fixed issue with modifier location overrides

Expand Down
47 changes: 47 additions & 0 deletions lib/src/functions_model/create_customer_group.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:square_connect/square_connect.dart';

part 'create_customer_group.g.dart';

@JsonSerializable()
class CreateCustomerGroupRequest extends Equatable {
const CreateCustomerGroupRequest({
this.group,
this.idempotencyKey,
});

/// Converts a [Map] to an [CreateCustomerGroupRequest]
factory CreateCustomerGroupRequest.fromJson(Map<String, dynamic> json) =>
_$CreateCustomerGroupRequestFromJson(json);

/// Converts a [CreateCustomerGroupRequest] to a [Map]
Map<String, dynamic> toJson() => _$CreateCustomerGroupRequestToJson(this);

/// The idempotency key for the request.
final String? idempotencyKey;

/// The customer group to create.
final CustomerGroup? group;

@override
List<Object?> get props => [idempotencyKey, group];
}

@JsonSerializable()
class CreateCustomerGroupResponse extends SquareResponse {
const CreateCustomerGroupResponse({this.group, super.errors});

/// Converts a [Map] to an [CreateCustomerGroupResponse]
factory CreateCustomerGroupResponse.fromJson(Map<String, dynamic> json) =>
_$CreateCustomerGroupResponseFromJson(json);

/// Converts a [CreateCustomerGroupResponse] to a [Map]
Map<String, dynamic> toJson() => _$CreateCustomerGroupResponseToJson(this);

/// The successfully created customer group.
final CustomerGroup? group;

@override
List<Object?> get props => [group, errors];
}
57 changes: 57 additions & 0 deletions lib/src/functions_model/create_customer_group.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/functions_model/create_payment_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CreatePaymentLinkRequest extends Equatable {
order,
checkoutOptions,
prePopulatedData,
paymentNote
paymentNote,
];
}

Expand Down
19 changes: 19 additions & 0 deletions lib/src/functions_model/delete_customer_group.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:square_connect/square_connect.dart';

part 'delete_customer_group.g.dart';

@JsonSerializable()
class DeleteCustomerGroupResponse extends SquareResponse {
const DeleteCustomerGroupResponse({super.errors});

/// Converts a [Map] to an [DeleteCustomerGroupResponse]
factory DeleteCustomerGroupResponse.fromJson(Map<String, dynamic> json) =>
_$DeleteCustomerGroupResponseFromJson(json);

/// Converts a [DeleteCustomerGroupResponse] to a [Map]
Map<String, dynamic> toJson() => _$DeleteCustomerGroupResponseToJson(this);

@override
List<Object?> get props => [errors];
}
29 changes: 29 additions & 0 deletions lib/src/functions_model/delete_customer_group.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions lib/src/functions_model/functions_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export 'clone_order.dart';
export 'create_card.dart';
export 'create_checkout.dart';
export 'create_customer.dart';
export 'create_customer_group.dart';
export 'create_gift_card.dart';
export 'create_gift_card_activity.dart';
export 'create_invoice.dart';
Expand All @@ -21,6 +22,7 @@ export 'create_payment.dart';
export 'create_payment_link.dart';
export 'create_subscription.dart';
export 'delete_customer.dart';
export 'delete_customer_group.dart';
export 'delete_invoice.dart';
export 'delete_loyalty_reward.dart';
export 'delete_subscription_action.dart';
Expand All @@ -29,6 +31,8 @@ export 'get_invoice.dart';
export 'link_customer_to_gift_card.dart';
export 'list_cards.dart';
export 'list_catalog.dart';
export 'list_customer_groups.dart';
export 'list_customer_segments.dart';
export 'list_customers.dart';
export 'list_gift_cards.dart';
export 'list_invoices.dart';
Expand All @@ -45,6 +49,8 @@ export 'resume_subscription.dart';
export 'retrieve_card.dart';
export 'retrieve_catalog_objects.dart';
export 'retrieve_customer.dart';
export 'retrieve_customer_group.dart';
export 'retrieve_customer_segment.dart';
export 'retrieve_gift_card.dart';
export 'retrieve_gift_card_from_gan.dart';
export 'retrieve_gift_card_from_nonce.dart';
Expand All @@ -67,6 +73,7 @@ export 'search_subscriptions.dart';
export 'swap_plan.dart';
export 'unlink_customer_from_gift_card.dart';
export 'update_customer.dart';
export 'update_customer_group.dart';
export 'update_invoice.dart';
export 'update_location.dart';
export 'update_order.dart';
Expand Down
31 changes: 31 additions & 0 deletions lib/src/functions_model/list_customer_groups.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:square_connect/square_connect.dart';

part 'list_customer_groups.g.dart';

@JsonSerializable()
class ListCustomerGroupsResponse extends SquareResponse {
const ListCustomerGroupsResponse({
this.groups,
this.cursor,
super.errors,
});

/// Converts a [Map] to an [ListCustomerGroupsResponse]
factory ListCustomerGroupsResponse.fromJson(Map<String, dynamic> json) =>
_$ListCustomerGroupsResponseFromJson(json);

/// Converts a [ListCustomerGroupsResponse] to a [Map]
Map<String, dynamic> toJson() => _$ListCustomerGroupsResponseToJson(this);

/// A list of customer groups belonging to the current seller.
final List<CustomerGroup>? groups;

/// A pagination cursor to retrieve the next set of results for your
/// original query to the endpoint. This value is present only if the
/// request succeeded and additional results are available.
final String? cursor;

@override
List<Object?> get props => [groups, cursor, errors];
}
35 changes: 35 additions & 0 deletions lib/src/functions_model/list_customer_groups.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions lib/src/functions_model/list_customer_segments.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:square_connect/square_connect.dart';

part 'list_customer_segments.g.dart';

@JsonSerializable()
class ListCustomerSegmentsResponse extends SquareResponse {
const ListCustomerSegmentsResponse({
this.segments,
this.cursor,
super.errors,
});

/// Converts a [Map] to an [ListCustomerSegmentsResponse]
factory ListCustomerSegmentsResponse.fromJson(Map<String, dynamic> json) =>
_$ListCustomerSegmentsResponseFromJson(json);

/// Converts a [ListCustomerSegmentsResponse] to a [Map]
Map<String, dynamic> toJson() => _$ListCustomerSegmentsResponseToJson(this);

/// The list of customer segments belonging to the associated Square account.
final List<CustomerSegment>? segments;

/// A pagination cursor to be used in subsequent calls to
/// ListCustomerSegments to retrieve the next set of query results. The cursor
/// is only present if the request succeeded and additional results are
/// available.
final String? cursor;

@override
List<Object?> get props => [segments, cursor, errors];
}
35 changes: 35 additions & 0 deletions lib/src/functions_model/list_customer_segments.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions lib/src/functions_model/retrieve_customer_group.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:square_connect/square_connect.dart';

part 'retrieve_customer_group.g.dart';

@JsonSerializable()
class RetrieveCustomerGroupResponse extends SquareResponse {
const RetrieveCustomerGroupResponse({this.group, super.errors});

/// Converts a [Map] to an [RetrieveCustomerGroupResponse]
factory RetrieveCustomerGroupResponse.fromJson(Map<String, dynamic> json) =>
_$RetrieveCustomerGroupResponseFromJson(json);

/// Converts a [RetrieveCustomerGroupResponse] to a [Map]
Map<String, dynamic> toJson() => _$RetrieveCustomerGroupResponseToJson(this);

final CustomerGroup? group;

@override
List<Object?> get props => [group, errors];
}
Loading
Loading