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