@@ -83,6 +83,37 @@ func (r *ConsumerService) Update(ctx context.Context, queueID string, consumerID
8383 return
8484}
8585
86+ // Returns the consumers for a Queue
87+ func (r * ConsumerService ) List (ctx context.Context , queueID string , query ConsumerListParams , opts ... option.RequestOption ) (res * pagination.SinglePage [Consumer ], err error ) {
88+ var raw * http.Response
89+ opts = append (r .Options [:], opts ... )
90+ opts = append ([]option.RequestOption {option .WithResponseInto (& raw )}, opts ... )
91+ if query .AccountID .Value == "" {
92+ err = errors .New ("missing required account_id parameter" )
93+ return
94+ }
95+ if queueID == "" {
96+ err = errors .New ("missing required queue_id parameter" )
97+ return
98+ }
99+ path := fmt .Sprintf ("accounts/%s/queues/%s/consumers" , query .AccountID , queueID )
100+ cfg , err := requestconfig .NewRequestConfig (ctx , http .MethodGet , path , nil , & res , opts ... )
101+ if err != nil {
102+ return nil , err
103+ }
104+ err = cfg .Execute ()
105+ if err != nil {
106+ return nil , err
107+ }
108+ res .SetPageConfig (cfg , raw )
109+ return res , nil
110+ }
111+
112+ // Returns the consumers for a Queue
113+ func (r * ConsumerService ) ListAutoPaging (ctx context.Context , queueID string , query ConsumerListParams , opts ... option.RequestOption ) * pagination.SinglePageAutoPager [Consumer ] {
114+ return pagination .NewSinglePageAutoPager (r .List (ctx , queueID , query , opts ... ))
115+ }
116+
86117// Deletes the consumer for a queue.
87118func (r * ConsumerService ) Delete (ctx context.Context , queueID string , consumerID string , body ConsumerDeleteParams , opts ... option.RequestOption ) (res * ConsumerDeleteResponse , err error ) {
88119 opts = append (r .Options [:], opts ... )
@@ -103,11 +134,10 @@ func (r *ConsumerService) Delete(ctx context.Context, queueID string, consumerID
103134 return
104135}
105136
106- // Returns the consumers for a Queue
107- func (r * ConsumerService ) Get (ctx context.Context , queueID string , query ConsumerGetParams , opts ... option.RequestOption ) (res * pagination. SinglePage [ Consumer ] , err error ) {
108- var raw * http. Response
137+ // Fetches the consumer for a queue by consumer id
138+ func (r * ConsumerService ) Get (ctx context.Context , queueID string , consumerID string , query ConsumerGetParams , opts ... option.RequestOption ) (res * Consumer , err error ) {
139+ var env ConsumerGetResponseEnvelope
109140 opts = append (r .Options [:], opts ... )
110- opts = append ([]option.RequestOption {option .WithResponseInto (& raw )}, opts ... )
111141 if query .AccountID .Value == "" {
112142 err = errors .New ("missing required account_id parameter" )
113143 return
@@ -116,22 +146,17 @@ func (r *ConsumerService) Get(ctx context.Context, queueID string, query Consume
116146 err = errors .New ("missing required queue_id parameter" )
117147 return
118148 }
119- path := fmt .Sprintf ("accounts/%s/queues/%s/consumers" , query .AccountID , queueID )
120- cfg , err := requestconfig .NewRequestConfig (ctx , http .MethodGet , path , nil , & res , opts ... )
121- if err != nil {
122- return nil , err
149+ if consumerID == "" {
150+ err = errors .New ("missing required consumer_id parameter" )
151+ return
123152 }
124- err = cfg .Execute ()
153+ path := fmt .Sprintf ("accounts/%s/queues/%s/consumers/%s" , query .AccountID , queueID , consumerID )
154+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodGet , path , nil , & env , opts ... )
125155 if err != nil {
126- return nil , err
156+ return
127157 }
128- res .SetPageConfig (cfg , raw )
129- return res , nil
130- }
131-
132- // Returns the consumers for a Queue
133- func (r * ConsumerService ) GetAutoPaging (ctx context.Context , queueID string , query ConsumerGetParams , opts ... option.RequestOption ) * pagination.SinglePageAutoPager [Consumer ] {
134- return pagination .NewSinglePageAutoPager (r .Get (ctx , queueID , query , opts ... ))
158+ res = & env .Result
159+ return
135160}
136161
137162type Consumer struct {
@@ -865,6 +890,11 @@ func (r ConsumerUpdateResponseEnvelopeSuccess) IsKnown() bool {
865890 return false
866891}
867892
893+ type ConsumerListParams struct {
894+ // A Resource identifier.
895+ AccountID param.Field [string ] `path:"account_id,required"`
896+ }
897+
868898type ConsumerDeleteParams struct {
869899 // A Resource identifier.
870900 AccountID param.Field [string ] `path:"account_id,required"`
@@ -874,3 +904,46 @@ type ConsumerGetParams struct {
874904 // A Resource identifier.
875905 AccountID param.Field [string ] `path:"account_id,required"`
876906}
907+
908+ type ConsumerGetResponseEnvelope struct {
909+ Errors []shared.ResponseInfo `json:"errors"`
910+ Messages []string `json:"messages"`
911+ Result Consumer `json:"result"`
912+ // Indicates if the API call was successful or not.
913+ Success ConsumerGetResponseEnvelopeSuccess `json:"success"`
914+ JSON consumerGetResponseEnvelopeJSON `json:"-"`
915+ }
916+
917+ // consumerGetResponseEnvelopeJSON contains the JSON metadata for the struct
918+ // [ConsumerGetResponseEnvelope]
919+ type consumerGetResponseEnvelopeJSON struct {
920+ Errors apijson.Field
921+ Messages apijson.Field
922+ Result apijson.Field
923+ Success apijson.Field
924+ raw string
925+ ExtraFields map [string ]apijson.Field
926+ }
927+
928+ func (r * ConsumerGetResponseEnvelope ) UnmarshalJSON (data []byte ) (err error ) {
929+ return apijson .UnmarshalRoot (data , r )
930+ }
931+
932+ func (r consumerGetResponseEnvelopeJSON ) RawJSON () string {
933+ return r .raw
934+ }
935+
936+ // Indicates if the API call was successful or not.
937+ type ConsumerGetResponseEnvelopeSuccess bool
938+
939+ const (
940+ ConsumerGetResponseEnvelopeSuccessTrue ConsumerGetResponseEnvelopeSuccess = true
941+ )
942+
943+ func (r ConsumerGetResponseEnvelopeSuccess ) IsKnown () bool {
944+ switch r {
945+ case ConsumerGetResponseEnvelopeSuccessTrue :
946+ return true
947+ }
948+ return false
949+ }
0 commit comments