• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ArrowSphere / nodejs-api-client / #8611

23 May 2025 12:39PM UTC coverage: 95.229% (-0.01%) from 95.241%
#8611

Pull #684

tbottini-arrow
Merge branch 'main' into ARE-48053-list-partner-subscriptions
Pull Request #684: ARE-48053-fix(subscriptions): list should returns partner subscriptions

1370 of 1502 branches covered (91.21%)

Branch coverage included in aggregate %.

5 of 6 new or added lines in 2 files covered. (83.33%)

5 existing lines in 1 file now uncovered.

7113 of 7406 relevant lines covered (96.04%)

7.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.74
/src/subscriptions/subscriptionsClient.ts
1
/**
2
 * Class SubscriptionsClient
3
 */
4
import { AbstractRestfulClient } from '../abstractRestfulClient';
1✔
5
import { SubscriptionData } from './entities/subscription';
6
import { SubscriptionsListResult } from './entities/subscriptionsListResult';
1✔
7

8
export type SubscriptionsListPayload = {
9
  subscription?: string[];
10
  status?: string[];
11
  partnerTag?: string[];
12
  marketplace?: string[];
13
  company?: string[];
14
  startDate?: string;
15
  endingDate?: string;
16
  lastUpdate?: string;
17
  perPage?: string;
18
  page?: string;
19
  sortBy?: string;
20
  sortDirection?: 'ASC' | 'DESC';
21
};
22

23
export type AdminSubscriptionsListData = {
24
  data: Array<SubscriptionData>;
25
  pagination: {
26
    perPage: number;
27
    currentPage: number;
28
    totalPage: number;
29
    total: number;
30
    next: string;
31
    previous: string;
32
  };
33
};
34

35
export type PartnerSubscriptionsListData = {
36
  data: Array<PartnerSubscription>;
37
  status: number;
38
};
39

40
export type PartnerSubscription = {
41
  reference: string;
42
  name: string;
43
  status: string;
44
  dateDemand: string;
45
  dateValidation: string | null;
46
  dateEnd: string | null;
47
  level: string | null;
48
  error_msg: string | null;
49
  details: {
50
    partnerId: string;
51
  };
52
  extraInformation: {
53
    programs: Record<
54
      string,
55
      {
56
        partnerId: string;
57
      }
58
    >;
59
  };
60
};
61

62
export type SubscriptionCreationData = {
63
  name: string;
64
  level: string;
65
  sku: string;
66
  extraInformation?: {
67
    programs: {
68
      [programName: string]: Record<string, string | boolean>;
69
    };
70
  };
71
};
72

73
export class SubscriptionsClient extends AbstractRestfulClient {
1✔
74
  /**
75
   * The base path of the API
76
   */
77
  protected basePath = '/subscriptions';
2✔
78

79
  /**
80
   * The path of the List endpoint
81
   */
82
  private LIST_PATH = '';
2✔
83

84
  /**
85
   * Pagination for these endpoints are camel cased (`&perPage=x` instead of `&per_page=x`)
86
   */
87
  protected isCamelPagination = true;
2✔
88

89
  /**
90
   * @deprecated use listAdmin instead
91
   * Calls the admin subscriptions API list endpoint
92
   *
93
   * @param data - List payload
94
   *
95
   * @returns Promise\<AxiosResponse\<{@link AdminSubscriptionsListData}\>\>   */
96
  public async listRaw(
97
    data: SubscriptionsListPayload = {},
1✔
98
  ): Promise<AdminSubscriptionsListData> {
99
    this.path = this.LIST_PATH;
8✔
100
    return this.get<AdminSubscriptionsListData>(data, {}, { isAdmin: true });
8✔
101
  }
102

103
  /**
104
   * Lists subscriptions and returns a SubscriptionsListResult to manipulate the results.
105
   *
106
   * Note: This endpoint requires an admin token to be called
107
   *
108
   * @param filters - List payload
109
   * @param perPage - Number of results per page
110
   * @param page - Page number to fetch
111
   *
112
   * @returns Promise\<{@link SubscriptionsListResult}\>
113
   *
114
   */
115
  public async list(
116
    filters: SubscriptionsListPayload = {},
1✔
117
  ): Promise<PartnerSubscriptionsListData> {
118
    return this.get<PartnerSubscriptionsListData>(
1✔
119
      filters,
120
      {},
121
      { isAdmin: false },
122
    );
123
  }
124

125
  public async listAdmin(
126
    filters: SubscriptionsListPayload = {},
4✔
127
    perPage = 100,
3✔
128
    page = 1,
3✔
129
  ) {
130
    this.setPerPage(perPage);
4✔
131
    this.setPage(page);
4✔
132

133
    const response = await this.listRaw(filters);
4✔
134

135
    return new SubscriptionsListResult(response, this, filters);
4✔
136
  }
137

138
  public async addSubscription(
139
    filters: SubscriptionCreationData,
140
  ): Promise<void> {
NEW
141
    return this.post(filters);
×
142
  }
143
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc