Class: Mints::User

Inherits:
Object
  • Object
show all
Defined in:
lib/user.rb

Overview

User context API

User class contains functions that needs an API key and a session token as authentication

Usage example

Initialize

client = Mints::User.new(mints_url, api_key)

Call any function

client.get_contacts

Single resource options

  • include - [String] include a relationship

  • attributes - [Boolean] attach attributes to response

  • categories - [Boolean] attach categories to response

  • tags - [Boolean] attach tags to response

Resource collections options

  • search - [String] filter by a search word

  • scopes - [String] filter by a scope

  • filters - [String] filter by where clauses

  • jfilters - [String] filter using complex condition objects

  • catfilters - [String] filter by categories

  • fields - [String] indicates the columns that will be selected

  • sort - [String] indicates the columns that will be selected

  • include - [String] include a relationship

  • attributes - [Boolean] attach attributes to response

  • categories - [Boolean] attach categories to response

  • taxonomies - [Boolean] attach categories to response

  • tags - [Boolean] attach tags to response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, api_key, session_token = nil, debug = false) ⇒ User

Returns a new instance of User.



31
32
33
# File 'lib/user.rb', line 31

def initialize(host, api_key, session_token = nil, debug = false)
  @client = Mints::Client.new(host, api_key, 'user', session_token, nil, debug)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



30
31
32
# File 'lib/user.rb', line 30

def client
  @client
end

Instance Method Details

#create_company(data, options = nil) ⇒ Object



107
108
109
# File 'lib/user.rb', line 107

def create_company(data, options = nil)
  return @client.create__crm__companies(data, options)
end

#create_contact(data, options = nil) ⇒ Object



86
87
88
# File 'lib/user.rb', line 86

def create_contact(data, options = nil)
  return @client.create__crm__contacts(data, options)
end

#create_content_instance(data, options = nil) ⇒ Object



192
193
194
# File 'lib/user.rb', line 192

def create_content_instance(data, options = nil)
  return @client.create__content__instances(data, options)
end

#create_content_page(data, options = nil) ⇒ Object



213
214
215
# File 'lib/user.rb', line 213

def create_content_page(data, options = nil)
  return @client.create__content__pages(data, options)
end

#create_content_template(data, options = nil) ⇒ Object



234
235
236
# File 'lib/user.rb', line 234

def create_content_template(data, options = nil)
  return @client.create__content__templates(data, options)
end

#create_deal(data, options = nil) ⇒ Object



128
129
130
# File 'lib/user.rb', line 128

def create_deal(data, options = nil)
  return @client.create__crm__deals(data, options)
end

#create_location(data, options = nil) ⇒ Object



403
404
405
# File 'lib/user.rb', line 403

def create_location(data, options = nil)
  return @client.create__ecommerce__locations(data, options)
end

#create_price(data, options = nil) ⇒ Object



297
298
299
# File 'lib/user.rb', line 297

def create_price(data, options = nil)
  return @client.create__ecommerce__prices(data, options)
end

#create_price_list(data, options = nil) ⇒ Object



318
319
320
# File 'lib/user.rb', line 318

def create_price_list(data, options = nil)
  return @client.create__ecommerce__price_lists(data, options)
end

#create_prodict_brand(data, options = nil) ⇒ Object



339
340
341
# File 'lib/user.rb', line 339

def create_prodict_brand(data, options = nil)
  return @client.create__ecommerce__product_brands(data, options)
end

#create_prodict_template(data, options = nil) ⇒ Object



381
382
383
# File 'lib/user.rb', line 381

def create_prodict_template(data, options = nil)
  return @client.create__ecommerce__product_templates(data, options)
end

#create_prodict_type(data, options = nil) ⇒ Object



360
361
362
# File 'lib/user.rb', line 360

def create_prodict_type(data, options = nil)
  return @client.create__ecommerce__product_types(data, options)
end

#create_product(data, options = nil) ⇒ Object



255
256
257
# File 'lib/user.rb', line 255

def create_product(data, options = nil)
  return @client.create__ecommerce__products(data, options)
end

#create_sku(data, options = nil) ⇒ Object



276
277
278
# File 'lib/user.rb', line 276

def create_sku(data, options = nil)
  return @client.create__ecommerce__skus(data, options)
end

#create_story(data, options = nil) ⇒ Object



150
151
152
# File 'lib/user.rb', line 150

def create_story(data, options = nil)
  return @client.create__content__stories(data, options)
end

#create_story_template(data, options = nil) ⇒ Object



171
172
173
# File 'lib/user.rb', line 171

def create_story_template(data, options = nil)
  return @client.create__content__story_templates(data, options)
end

#create_taxonomy(data, options = nil) ⇒ Object



424
425
426
# File 'lib/user.rb', line 424

def create_taxonomy(data, options = nil)
  return @client.create__config__taxonomies(data, options)
end

#get_companies(options = nil) ⇒ Object

Get companies.

Get a collection of companies

Parameters



99
100
101
# File 'lib/user.rb', line 99

def get_companies(options = nil)
  return @client.get__crm__companies(options)
end

#get_company(id, options = nil) ⇒ Object



103
104
105
# File 'lib/user.rb', line 103

def get_company(id, options = nil)
  return @client.get__crm__companies(id, options)
end

#get_contact(id, options = nil) ⇒ Object



82
83
84
# File 'lib/user.rb', line 82

def get_contact(id, options = nil)
  return @client.get__crm__contacts(id, options)
end

#get_contacts(options = nil) ⇒ Object

CRM #########################################

Get contacts.

Get a collection of contacts

Parameters



78
79
80
# File 'lib/user.rb', line 78

def get_contacts(options = nil)
  return @client.get__crm__contacts(options)
end

#get_content_instance(id, options = nil) ⇒ Object



188
189
190
# File 'lib/user.rb', line 188

def get_content_instance(id, options = nil)
  return @client.get__content__instances(id, options)
end

#get_content_instances(options = nil) ⇒ Object

Get content instances.

Get a collection of content instances

Parameters



184
185
186
# File 'lib/user.rb', line 184

def get_content_instances(options = nil)
  return @client.get__content__instances(options)
end

#get_content_page(id, options = nil) ⇒ Object



209
210
211
# File 'lib/user.rb', line 209

def get_content_page(id, options = nil)
  return @client.get__content__pages(id, options)
end

#get_content_pages(options = nil) ⇒ Object

Get content pages.

Get a collection of content pages

Parameters



205
206
207
# File 'lib/user.rb', line 205

def get_content_pages(options = nil)
  return @client.get__content__pages(options)
end

#get_content_template(id, options = nil) ⇒ Object



230
231
232
# File 'lib/user.rb', line 230

def get_content_template(id, options = nil)
  return @client.get__content__templates(id, options)
end

#get_content_templates(options = nil) ⇒ Object

Get content templates.

Get a collection of content templates

Parameters



226
227
228
# File 'lib/user.rb', line 226

def get_content_templates(options = nil)
  return @client.get__content__templates(options)
end

#get_deal(id, options = nil) ⇒ Object



124
125
126
# File 'lib/user.rb', line 124

def get_deal(id, options = nil)
  return @client.get__crm__deals(id, options)
end

#get_deals(options = nil) ⇒ Object

Get deals.

Get a collection of deals

Parameters



120
121
122
# File 'lib/user.rb', line 120

def get_deals(options = nil)
  return @client.get__crm__deals(options)
end

#get_location(id, options = nil) ⇒ Object



399
400
401
# File 'lib/user.rb', line 399

def get_location(id, options = nil)
  return @client.get__ecommerce__locations(id, options)
end

#get_locations(options = nil) ⇒ Object

Get locations.

Get a collection of locations

Parameters



395
396
397
# File 'lib/user.rb', line 395

def get_locations(options = nil)
  return @client.get__ecommerce__locations(options)
end

#get_price(id, options = nil) ⇒ Object



293
294
295
# File 'lib/user.rb', line 293

def get_price(id, options = nil)
  return @client.get__ecommerce__prices(id, options)
end

#get_price_list(id, options = nil) ⇒ Object



314
315
316
# File 'lib/user.rb', line 314

def get_price_list(id, options = nil)
  return @client.get__ecommerce__price_lists(id, options)
end

#get_price_lists(options = nil) ⇒ Object

Get prece lists.

Get a collection of prece lists

Parameters



310
311
312
# File 'lib/user.rb', line 310

def get_price_lists(options = nil)
  return @client.get__ecommerce__price_lists(options)
end

#get_prices(options = nil) ⇒ Object

Get prices.

Get a collection of prices

Parameters



289
290
291
# File 'lib/user.rb', line 289

def get_prices(options = nil)
  return @client.get__ecommerce__prices(options)
end

#get_prodict_brand(id, options = nil) ⇒ Object



335
336
337
# File 'lib/user.rb', line 335

def get_prodict_brand(id, options = nil)
  return @client.get__ecommerce__product_brands(id, options)
end

#get_prodict_template(id, options = nil) ⇒ Object



377
378
379
# File 'lib/user.rb', line 377

def get_prodict_template(id, options = nil)
  return @client.get__ecommerce__product_templates(id, options)
end

#get_prodict_type(id, options = nil) ⇒ Object



356
357
358
# File 'lib/user.rb', line 356

def get_prodict_type(id, options = nil)
  return @client.get__ecommerce__product_types(id, options)
end

#get_product(id, options = nil) ⇒ Object



251
252
253
# File 'lib/user.rb', line 251

def get_product(id, options = nil)
  return @client.get__ecommerce__products(id, options)
end

#get_product_brands(options = nil) ⇒ Object

Get product brands.

Get a collection of product brands

Parameters



331
332
333
# File 'lib/user.rb', line 331

def get_product_brands(options = nil)
  return @client.get__ecommerce__product_brands(options)
end

#get_product_templates(options = nil) ⇒ Object

Get product templates.

Get a collection of product templates

Parameters



373
374
375
# File 'lib/user.rb', line 373

def get_product_templates(options = nil)
  return @client.get__ecommerce__product_templates(options)
end

#get_product_types(options = nil) ⇒ Object

Get product types.

Get a collection of product types

Parameters



352
353
354
# File 'lib/user.rb', line 352

def get_product_types(options = nil)
  return @client.get__ecommerce__product_types(options)
end

#get_products(options = nil) ⇒ Object

Get products.

Get a collection of products

Parameters



247
248
249
# File 'lib/user.rb', line 247

def get_products(options = nil)
  return @client.get__ecommerce__products(options)
end

#get_sku(id, options = nil) ⇒ Object



272
273
274
# File 'lib/user.rb', line 272

def get_sku(id, options = nil)
  return @client.get__ecommerce__skus(id, options)
end

#get_skus(options = nil) ⇒ Object

Get skus.

Get a collection of skus

Parameters



268
269
270
# File 'lib/user.rb', line 268

def get_skus(options = nil)
  return @client.get__ecommerce__skus(options)
end

#get_stories(options = nil) ⇒ Object

Content #########################################

Get stories.

Get a collection of stories

Parameters



142
143
144
# File 'lib/user.rb', line 142

def get_stories(options = nil)
  return @client.get__content__stories(options)
end

#get_story(id, options = nil) ⇒ Object



146
147
148
# File 'lib/user.rb', line 146

def get_story(id, options = nil)
  return @client.get__content__stories(id, options)
end

#get_story_template(id, options = nil) ⇒ Object



167
168
169
# File 'lib/user.rb', line 167

def get_story_template(id, options = nil)
  return @client.get__content__story_templates(id, options)
end

#get_story_templates(options = nil) ⇒ Object

Get story templates.

Get a collection of story templates

Parameters



163
164
165
# File 'lib/user.rb', line 163

def get_story_templates(options = nil)
  return @client.get__content__story_templates(options)
end

#get_taxonomies(options = nil) ⇒ Object

Get taxonomies.

Get a collection of taxonomies

Parameters



416
417
418
# File 'lib/user.rb', line 416

def get_taxonomies(options = nil)
  return @client.get__config__taxonomies(options)
end

#get_taxonomy(id, options = nil) ⇒ Object



420
421
422
# File 'lib/user.rb', line 420

def get_taxonomy(id, options = nil)
  return @client.get__config__taxonomies(id, options)
end

#login(email, password) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/user.rb', line 35

def (email, password)
  data = {
    email: email,
    password: password,
  }
  response = @client.raw("post", "/users/login", nil, data, '/api/v1')
  if response.key? "api_token"
    @client.session_token = response["api_token"]
  end
  return response
end


47
48
49
50
# File 'lib/user.rb', line 47

def (token)
  response = @client.raw("get", "/users/magic-link-login/#{token}", nil, nil, '/api/v1')
  return response
end

#meObject

Me.

Get contact logged info



68
69
70
# File 'lib/user.rb', line 68

def me
  return @client.get__profile__me
end

Send magic link to user



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

def send_magic_link(email, redirectUrl = '', lifeTime = 24)
  data = {
    email: email,
    redirectUrl: redirectUrl,
    lifeTime: lifeTime
  }
  response = @client.raw("post", "/users/magic-link", nil, { data: data }, '/api/v1')
  return response
end

#update_company(id, data, options = nil) ⇒ Object



111
112
113
# File 'lib/user.rb', line 111

def update_company(id, data, options = nil)
  return @client.update__crm__companies(id, data, options)
end

#update_contact(id, data, options = nil) ⇒ Object



90
91
92
# File 'lib/user.rb', line 90

def update_contact(id, data, options = nil)
  return @client.update__crm__contacts(id, data, options)
end

#update_content_instance(id, data, options = nil) ⇒ Object



196
197
198
# File 'lib/user.rb', line 196

def update_content_instance(id, data, options = nil)
  return @client.update__content__instances(id, data, options)
end

#update_content_page(id, data, options = nil) ⇒ Object



217
218
219
# File 'lib/user.rb', line 217

def update_content_page(id, data, options = nil)
  return @client.update__content__pages(id, data, options)
end

#update_content_template(id, data, options = nil) ⇒ Object



238
239
240
# File 'lib/user.rb', line 238

def update_content_template(id, data, options = nil)
  return @client.update__content__templates(id, data, options)
end

#update_deal(id, data, options = nil) ⇒ Object



132
133
134
# File 'lib/user.rb', line 132

def update_deal(id, data, options = nil)
  return @client.update__crm__deals(id, data, options)
end

#update_location(id, data, options = nil) ⇒ Object



407
408
409
# File 'lib/user.rb', line 407

def update_location(id, data, options = nil)
  return @client.update__ecommerce__locations(id, data, options)
end

#update_price(id, data, options = nil) ⇒ Object



301
302
303
# File 'lib/user.rb', line 301

def update_price(id, data, options = nil)
  return @client.update__ecommerce__prices(id, data, options)
end

#update_price_list(id, data, options = nil) ⇒ Object



322
323
324
# File 'lib/user.rb', line 322

def update_price_list(id, data, options = nil)
  return @client.update__ecommerce__price_lists(id, data, options)
end

#update_product(id, data, options = nil) ⇒ Object



259
260
261
# File 'lib/user.rb', line 259

def update_product(id, data, options = nil)
  return @client.update__ecommerce__products(id, data, options)
end

#update_product_brand(id, data, options = nil) ⇒ Object



343
344
345
# File 'lib/user.rb', line 343

def update_product_brand(id, data, options = nil)
  return @client.update__ecommerce__product_brands(id, data, options)
end

#update_product_template(id, data, options = nil) ⇒ Object



385
386
387
# File 'lib/user.rb', line 385

def update_product_template(id, data, options = nil)
  return @client.update__ecommerce__product_templates(id, data, options)
end

#update_product_type(id, data, options = nil) ⇒ Object



364
365
366
# File 'lib/user.rb', line 364

def update_product_type(id, data, options = nil)
  return @client.update__ecommerce__product_types(id, data, options)
end

#update_sku(id, data, options = nil) ⇒ Object



280
281
282
# File 'lib/user.rb', line 280

def update_sku(id, data, options = nil)
  return @client.update__ecommerce__skus(id, data, options)
end

#update_story(id, data, options = nil) ⇒ Object



154
155
156
# File 'lib/user.rb', line 154

def update_story(id, data, options = nil)
  return @client.update__content__stories(id, data, options)
end

#update_story_template(id, data, options = nil) ⇒ Object



175
176
177
# File 'lib/user.rb', line 175

def update_story_template(id, data, options = nil)
  return @client.update__content__story_templates(id, data, options)
end

#update_taxonomy(id, data, options = nil) ⇒ Object



428
429
430
# File 'lib/user.rb', line 428

def update_taxonomy(id, data, options = nil)
  return @client.update__config__taxonomies(id, data, options)
end