Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. // Asura (CustomerController.js)
  2.  
  3. static async postCustomerWithMagic(ctx, next) {
  4. // .. something something
  5. } else if (primary_id_type === 'customerId') {
  6. let { isProvisioned } = await api.classify(primary_id, primary_id_type);
  7. result = isProvisioned ? null :
  8. await api.provision(customer.id, 'spAccountId', customer.sku, effectiveDate, primary_id);
  9. } else {
  10. // .. something something
  11. ctx.json(result);
  12. }
  13.  
  14. // Wyvern (SignupController.js)
  15.  
  16. *postOtp()
  17. {
  18. var activationResult = {};
  19. try {
  20. activationResult = yield postCustomer(this.session.country, this.request.body);
  21. } catch (err) {
  22. // FIXME: handle when activation failed
  23. // however e.g. for telkomsel, the user is already provisioned
  24. }
  25.  
  26. var createPath = activationResult.type === 'spAccountId' ? 'partnersCreateCustomer' : 'createCustomer';
  27.  
  28. // create user
  29. var customerParam = {
  30. ipAddress: process.env[this.session.country + '_CREDENTIALS_API_IP'],
  31. apiuser: process.env.EVERGENT_API_USER,
  32. apipassword: process.env.EVERGENT_API_PASSWORD,
  33. contactUserName: this.request.body.email,
  34. contactPassword: this.request.body.password,
  35. phoneNumber: sanitizePhone(this.request.body.phone),
  36. smsCode: this.request.body.otp, // <--- for primaryIdType === 'msisdn' || 'email'
  37. spAccountId: activationResult.type === 'spAccountId' && activationResult.primaryId, // <--- for primaryIdType === 'customerId'
  38. socialLoginID: this.request.body.socialid || null,
  39. socialLoginType: this.request.body.socialid ? 'Facebook' : null,
  40. channelPartnerID: this.request.body.cpid || process.env[this.session.country + '_CREDENTIALS_API_PARTNERID'],
  41. locale: process.env.EVERGENT_API_LOCALE
  42. },
  43. response = yield request.post({ url: process.env.EVERGENT_API_DOMAIN + createPath, form: customerParam });
  44.  
  45. response = JSON.parse(response.body);
  46.  
  47. // .. something something
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement