@@ -96,7 +96,7 @@ func (a *Affiliation) AddIdentity(identity *Identity) bool {
9696 endpoint := a .AffBaseURL + "/affiliation/" + url .PathEscape (a .ProjectSlug ) + "/add_identity/" + url .PathEscape (identity .Source )
9797 statusCode , res , err := a .httpClientProvider .Request (strings .TrimSpace (endpoint ), "POST" , headers , nil , queryParams )
9898 switch statusCode {
99- case http .StatusOK , http .StatusConflict :
99+ case http .StatusOK , http .StatusConflict , http . StatusCreated :
100100 return true
101101 default :
102102 if err != nil {
@@ -109,10 +109,9 @@ func (a *Affiliation) AddIdentity(identity *Identity) bool {
109109 log .Println ("AddIdentity: failed to add identity: " , errMsg )
110110 }
111111
112- time .Sleep (5 * time .Minute )
112+ time .Sleep (2 * time .Minute )
113113 return a .AddIdentity (identity )
114114 }
115- return false
116115}
117116
118117// GetIdentity ...
@@ -221,12 +220,12 @@ func (a *Affiliation) GetIdentityByUser(key string, value string) (*AffIdentity,
221220 switch statusCode {
222221 case http .StatusBadRequest , http .StatusNotFound :
223222 log .Println ("GetIdentityByUser: Could not get the identity: l" , err )
224- return & AffIdentity {} , errors .New ("identity not found" )
223+ return nil , errors .New ("identity not found" )
225224 case http .StatusOK :
226225 default :
227226 if err != nil {
228227 log .Println ("GetIdentityByUser: Could not get the identity: " , err )
229- return & AffIdentity {} , err
228+ return nil , err
230229 }
231230
232231 var errMsg AffiliationsResponse
@@ -235,22 +234,22 @@ func (a *Affiliation) GetIdentityByUser(key string, value string) (*AffIdentity,
235234 log .Println ("GetIdentityByUser: failed to get identity: " , errMsg )
236235 }
237236
238- time .Sleep (5 * time .Minute )
237+ time .Sleep (2 * time .Minute )
239238 return a .GetIdentityByUser (key , value )
240239 }
241240
242241 var ident IdentityData
243242 err = json .Unmarshal (res , & ident )
244243 if err != nil {
245- return & AffIdentity {} , err
244+ return nil , err
246245 }
247246
248247 profileEndpoint := a .AffBaseURL + "/affiliation/" + url .PathEscape (a .ProjectSlug ) + "/get_profile/" + * ident .UUID
249248 statusCode , profileRes , err := a .httpClientProvider .Request (strings .TrimSpace (profileEndpoint ), "GET" , headers , nil , nil )
250249 switch statusCode {
251- case http .StatusBadRequest ,http .StatusNotFound :
250+ case http .StatusBadRequest , http .StatusNotFound :
252251 log .Println ("GetIdentityByUser: Could not get the identity: " , err )
253- return & AffIdentity {} , errors .New ("identity not found" )
252+ return nil , errors .New ("identity not found" )
254253 case http .StatusOK :
255254 default :
256255 if err != nil {
@@ -263,7 +262,7 @@ func (a *Affiliation) GetIdentityByUser(key string, value string) (*AffIdentity,
263262 log .Println ("GetIdentityByUser: failed to get identity profile: " , errMsg )
264263 }
265264
266- time .Sleep (5 * time .Minute )
265+ time .Sleep (2 * time .Minute )
267266 return a .GetIdentityByUser (key , value )
268267 }
269268
0 commit comments