Module: Yotpo::User

Included in:
Client
Defined in:
lib/yotpo/api/user.rb

Instance Method Summary collapse

Instance Method Details

#anonymous_user_confirmation(params) ⇒ Object



64
65
66
# File 'lib/yotpo/api/user.rb', line 64

def anonymous_user_confirmation(params)
  get("/users/anonymous/#{params[:token]}")
end

#create_user(params) ⇒ Object

Registers a new User with Yotpo

Parameters:

  • params (Hash)

    the user details hash

Options Hash (params):

  • :email (String)

    the email of the user

  • :display_name (String)

    the display name of the user

  • :first_name (String)

    the first name of the user

  • :last_name (String)

    the last name of the user

  • :website_name (String)

    the name of the web site that the user owns

  • :domain (String)

    the domain of the web site that the user owns

  • :url (String)

    the url of the web site that the user owns

  • :support_url (String)

    the support url at the users site

  • :callback_url (String)

    the beginning of the callback url at the users site

Returns:

  • the new account hash



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/yotpo/api/user.rb', line 18

def create_user(params)
  user = {
      email: params[:email],
      display_name: params[:display_name],
      first_name: params[:first_name],
      last_name: params[:last_name],
      website_name: params[:website_name],
      password: params[:password],
      support_url: params[:support_url],
      callback_url: params[:callback_url],
      url: params[:url]
  }
  post('/users', {user: user})
end

#get_login_url(params) ⇒ Object

To allow the login into www.yotpo.com using app_key and secret

Parameters:

  • params (Hash)

    the request params

Options Hash (params):

  • :app_key (String)

    that was received when registered to www.yotpo.com

  • :secret (String)

    that was received when registered to www.yotpo.com



56
57
58
59
60
61
62
# File 'lib/yotpo/api/user.rb', line 56

def (params)
  request = {
      app_key: params[:app_key],
      secret: params[:secret]
  }
  get('/users/b2blogin.json', request)
end

#get_oauth_token(params) ⇒ Hash

Retrieves an oauth bearer token from Yotpo

Parameters:

  • params (Hash)

    the request details

Options Hash (params):

  • :app_key (String)

    the app key received at the registration

  • :secret (String)

    app secret received at the registration

Returns:

  • (Hash)

    that includes access_token and the token_type



40
41
42
43
44
45
46
47
48
49
# File 'lib/yotpo/api/user.rb', line 40

def get_oauth_token(params)
  request = {
      client_id: params[:app_key],
      client_secret: params[:secret],
      grant_type: 'client_credentials'
  }

  response = post('/oauth/token', request)
  return response
end