@zubari/sdk 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -565,6 +565,403 @@ var ZubariApiClient = class {
565
565
  };
566
566
  }
567
567
  }
568
+ // ============ Tips Methods ============
569
+ /**
570
+ * Send a tip to a creator
571
+ */
572
+ async sendTip(params) {
573
+ try {
574
+ return await this.request("POST", "/api/tips", params);
575
+ } catch (error) {
576
+ return {
577
+ success: false,
578
+ error: error instanceof Error ? error.message : "Failed to send tip"
579
+ };
580
+ }
581
+ }
582
+ /**
583
+ * Get tip statistics for current user
584
+ */
585
+ async getTipStats() {
586
+ try {
587
+ const data = await this.request("GET", "/api/tips/my/stats");
588
+ return { success: true, ...data };
589
+ } catch (error) {
590
+ return {
591
+ success: false,
592
+ error: error instanceof Error ? error.message : "Failed to get tip stats"
593
+ };
594
+ }
595
+ }
596
+ /**
597
+ * Get tips sent by current user
598
+ */
599
+ async getSentTips(filters) {
600
+ try {
601
+ const params = new URLSearchParams();
602
+ if (filters) {
603
+ Object.entries(filters).forEach(([key, value]) => {
604
+ if (value !== void 0) {
605
+ params.append(key, String(value));
606
+ }
607
+ });
608
+ }
609
+ const queryString = params.toString();
610
+ const path = `/api/tips/sent${queryString ? `?${queryString}` : ""}`;
611
+ const data = await this.request("GET", path);
612
+ return { success: true, ...data };
613
+ } catch (error) {
614
+ return {
615
+ success: false,
616
+ error: error instanceof Error ? error.message : "Failed to get sent tips"
617
+ };
618
+ }
619
+ }
620
+ /**
621
+ * Get tips received by current user
622
+ */
623
+ async getReceivedTips(filters) {
624
+ try {
625
+ const params = new URLSearchParams();
626
+ if (filters) {
627
+ Object.entries(filters).forEach(([key, value]) => {
628
+ if (value !== void 0) {
629
+ params.append(key, String(value));
630
+ }
631
+ });
632
+ }
633
+ const queryString = params.toString();
634
+ const path = `/api/tips/received${queryString ? `?${queryString}` : ""}`;
635
+ const data = await this.request("GET", path);
636
+ return { success: true, ...data };
637
+ } catch (error) {
638
+ return {
639
+ success: false,
640
+ error: error instanceof Error ? error.message : "Failed to get received tips"
641
+ };
642
+ }
643
+ }
644
+ /**
645
+ * Get a single tip by ID
646
+ */
647
+ async getTip(tipId) {
648
+ try {
649
+ const data = await this.request("GET", `/api/tips/${tipId}`);
650
+ return { success: true, tip: data.tip };
651
+ } catch (error) {
652
+ return {
653
+ success: false,
654
+ error: error instanceof Error ? error.message : "Failed to get tip"
655
+ };
656
+ }
657
+ }
658
+ /**
659
+ * Update tip status (for transaction confirmation)
660
+ */
661
+ async updateTipStatus(tipId, params) {
662
+ try {
663
+ const data = await this.request(
664
+ "PATCH",
665
+ `/api/tips/${tipId}/status`,
666
+ params
667
+ );
668
+ return { success: true, ...data };
669
+ } catch (error) {
670
+ return {
671
+ success: false,
672
+ error: error instanceof Error ? error.message : "Failed to update tip status"
673
+ };
674
+ }
675
+ }
676
+ // ============ Subscription Methods ============
677
+ /**
678
+ * Create a new subscription plan (creator only)
679
+ */
680
+ async createSubscriptionPlan(params) {
681
+ try {
682
+ return await this.request("POST", "/api/subscriptions/plans", params);
683
+ } catch (error) {
684
+ return {
685
+ success: false,
686
+ error: error instanceof Error ? error.message : "Failed to create subscription plan"
687
+ };
688
+ }
689
+ }
690
+ /**
691
+ * Get current user's subscription plans
692
+ */
693
+ async getMySubscriptionPlans() {
694
+ try {
695
+ const data = await this.request("GET", "/api/subscriptions/plans");
696
+ return { success: true, plans: data.plans };
697
+ } catch (error) {
698
+ return {
699
+ success: false,
700
+ error: error instanceof Error ? error.message : "Failed to get subscription plans"
701
+ };
702
+ }
703
+ }
704
+ /**
705
+ * Get subscription plan by ID
706
+ */
707
+ async getSubscriptionPlan(planId) {
708
+ try {
709
+ const plan = await this.request(
710
+ "GET",
711
+ `/api/subscriptions/plans/${planId}`
712
+ );
713
+ return { success: true, plan };
714
+ } catch (error) {
715
+ return {
716
+ success: false,
717
+ error: error instanceof Error ? error.message : "Failed to get subscription plan"
718
+ };
719
+ }
720
+ }
721
+ /**
722
+ * Delete/deactivate subscription plan
723
+ */
724
+ async deleteSubscriptionPlan(planId) {
725
+ try {
726
+ const data = await this.request(
727
+ "DELETE",
728
+ `/api/subscriptions/plans/${planId}`
729
+ );
730
+ return { success: true, ...data };
731
+ } catch (error) {
732
+ return {
733
+ success: false,
734
+ error: error instanceof Error ? error.message : "Failed to delete subscription plan"
735
+ };
736
+ }
737
+ }
738
+ /**
739
+ * Subscribe to a plan
740
+ */
741
+ async subscribe(params) {
742
+ try {
743
+ return await this.request("POST", "/api/subscriptions/subscribe", params);
744
+ } catch (error) {
745
+ return {
746
+ success: false,
747
+ error: error instanceof Error ? error.message : "Failed to subscribe"
748
+ };
749
+ }
750
+ }
751
+ /**
752
+ * Get current user's subscriptions (as subscriber)
753
+ */
754
+ async getMySubscriptions(filters) {
755
+ try {
756
+ const params = new URLSearchParams();
757
+ if (filters) {
758
+ Object.entries(filters).forEach(([key, value]) => {
759
+ if (value !== void 0) {
760
+ params.append(key, String(value));
761
+ }
762
+ });
763
+ }
764
+ const queryString = params.toString();
765
+ const path = `/api/subscriptions${queryString ? `?${queryString}` : ""}`;
766
+ const data = await this.request("GET", path);
767
+ return { success: true, ...data };
768
+ } catch (error) {
769
+ return {
770
+ success: false,
771
+ error: error instanceof Error ? error.message : "Failed to get subscriptions"
772
+ };
773
+ }
774
+ }
775
+ /**
776
+ * Get subscribers to current user's plans (as creator)
777
+ */
778
+ async getMySubscribers(filters) {
779
+ try {
780
+ const params = new URLSearchParams();
781
+ if (filters) {
782
+ Object.entries(filters).forEach(([key, value]) => {
783
+ if (value !== void 0) {
784
+ params.append(key, String(value));
785
+ }
786
+ });
787
+ }
788
+ const queryString = params.toString();
789
+ const path = `/api/subscriptions/subscribers${queryString ? `?${queryString}` : ""}`;
790
+ const data = await this.request("GET", path);
791
+ return { success: true, ...data };
792
+ } catch (error) {
793
+ return {
794
+ success: false,
795
+ error: error instanceof Error ? error.message : "Failed to get subscribers"
796
+ };
797
+ }
798
+ }
799
+ /**
800
+ * Cancel subscription
801
+ */
802
+ async cancelSubscription(subscriptionId) {
803
+ try {
804
+ const data = await this.request("DELETE", `/api/subscriptions/${subscriptionId}`);
805
+ return { success: true, ...data };
806
+ } catch (error) {
807
+ return {
808
+ success: false,
809
+ error: error instanceof Error ? error.message : "Failed to cancel subscription"
810
+ };
811
+ }
812
+ }
813
+ /**
814
+ * Create a subscription plan on-chain
815
+ */
816
+ async createSubscriptionPlanOnChain(params) {
817
+ try {
818
+ return await this.request("POST", "/api/subscriptions/contract/plans", params);
819
+ } catch (error) {
820
+ return {
821
+ success: false,
822
+ error: error instanceof Error ? error.message : "Failed to create plan on-chain"
823
+ };
824
+ }
825
+ }
826
+ /**
827
+ * Subscribe to a plan on-chain
828
+ */
829
+ async subscribeOnChain(params) {
830
+ try {
831
+ return await this.request("POST", "/api/subscriptions/contract/subscribe", params);
832
+ } catch (error) {
833
+ return {
834
+ success: false,
835
+ error: error instanceof Error ? error.message : "Failed to subscribe on-chain"
836
+ };
837
+ }
838
+ }
839
+ /**
840
+ * Cancel subscription on-chain
841
+ */
842
+ async cancelSubscriptionOnChain(subscriptionId, seed) {
843
+ try {
844
+ return await this.request(
845
+ "POST",
846
+ "/api/subscriptions/contract/cancel",
847
+ { subscriptionId, seed }
848
+ );
849
+ } catch (error) {
850
+ return {
851
+ success: false,
852
+ error: error instanceof Error ? error.message : "Failed to cancel subscription on-chain"
853
+ };
854
+ }
855
+ }
856
+ /**
857
+ * Check if user is subscribed to a creator on-chain
858
+ */
859
+ async isSubscribed(subscriber, creator) {
860
+ try {
861
+ return await this.request(
862
+ "GET",
863
+ `/api/subscriptions/contract/is-subscribed?subscriber=${subscriber}&creator=${creator}`
864
+ );
865
+ } catch (error) {
866
+ return {
867
+ subscriber,
868
+ creator,
869
+ isSubscribed: false
870
+ };
871
+ }
872
+ }
873
+ /**
874
+ * Get subscription platform fee
875
+ */
876
+ async getSubscriptionPlatformFee() {
877
+ try {
878
+ return await this.request("GET", "/api/subscriptions/platform-fee");
879
+ } catch (error) {
880
+ return {
881
+ feeBps: 0,
882
+ feePercent: "0"
883
+ };
884
+ }
885
+ }
886
+ // ============ Payouts Methods ============
887
+ /**
888
+ * Get pending and claimed earnings for the authenticated user
889
+ */
890
+ async getEarnings() {
891
+ try {
892
+ const data = await this.request("GET", "/api/payouts/earnings");
893
+ return { success: true, ...data };
894
+ } catch (error) {
895
+ return {
896
+ success: false,
897
+ error: error instanceof Error ? error.message : "Failed to get earnings"
898
+ };
899
+ }
900
+ }
901
+ /**
902
+ * Claim pending earnings
903
+ */
904
+ async claimEarnings(params) {
905
+ try {
906
+ return await this.request("POST", "/api/payouts/claim", params);
907
+ } catch (error) {
908
+ return {
909
+ success: false,
910
+ error: error instanceof Error ? error.message : "Failed to claim earnings"
911
+ };
912
+ }
913
+ }
914
+ /**
915
+ * Get payout history for the authenticated user
916
+ */
917
+ async getPayoutHistory(filters) {
918
+ try {
919
+ const params = new URLSearchParams();
920
+ if (filters) {
921
+ Object.entries(filters).forEach(([key, value]) => {
922
+ if (value !== void 0) {
923
+ params.append(key, String(value));
924
+ }
925
+ });
926
+ }
927
+ const queryString = params.toString();
928
+ const path = `/api/payouts/history${queryString ? `?${queryString}` : ""}`;
929
+ const data = await this.request("GET", path);
930
+ return { success: true, ...data };
931
+ } catch (error) {
932
+ return {
933
+ success: false,
934
+ error: error instanceof Error ? error.message : "Failed to get payout history"
935
+ };
936
+ }
937
+ }
938
+ /**
939
+ * Get earnings breakdown by source
940
+ */
941
+ async getEarningsBreakdown() {
942
+ try {
943
+ const data = await this.request("GET", "/api/payouts/breakdown");
944
+ return { success: true, ...data };
945
+ } catch (error) {
946
+ return {
947
+ success: false,
948
+ error: error instanceof Error ? error.message : "Failed to get earnings breakdown"
949
+ };
950
+ }
951
+ }
952
+ /**
953
+ * Get current platform fee for payouts
954
+ */
955
+ async getPayoutsPlatformFee() {
956
+ try {
957
+ return await this.request("GET", "/api/payouts/platform-fee");
958
+ } catch (error) {
959
+ return {
960
+ feeBps: 0,
961
+ feePercent: "0"
962
+ };
963
+ }
964
+ }
568
965
  };
569
966
  var DEFAULT_API_URL2 = process.env.NEXT_PUBLIC_API_URL || "https://ckgwifsxka.us-east-2.awsapprunner.com";
570
967
  var zubariApiClient = null;