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.

[View source]

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, 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

[View source]

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

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

#create_contact(data, options = nil) ⇒ Object

[View source]

61
62
63
# File 'lib/user.rb', line 61

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

#create_content_instance(data, options = nil) ⇒ Object

[View source]

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

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

#create_content_page(data, options = nil) ⇒ Object

[View source]

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

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

#create_content_template(data, options = nil) ⇒ Object

[View source]

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

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

#create_deal(data, options = nil) ⇒ Object

[View source]

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

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

#create_location(data, options = nil) ⇒ Object

[View source]

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

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

#create_price(data, options = nil) ⇒ Object

[View source]

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

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

#create_price_list(data, options = nil) ⇒ Object

[View source]

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

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

#create_prodict_brand(data, options = nil) ⇒ Object

[View source]

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

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

#create_prodict_template(data, options = nil) ⇒ Object

[View source]

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

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

#create_prodict_type(data, options = nil) ⇒ Object

[View source]

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

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

#create_product(data, options = nil) ⇒ Object

[View source]

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

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

#create_sku(data, options = nil) ⇒ Object

[View source]

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

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

#create_story(data, options = nil) ⇒ Object

[View source]

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

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

#create_story_template(data, options = nil) ⇒ Object

[View source]

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

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

#create_taxonomy(data, options = nil) ⇒ Object

[View source]

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

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

[View source]

74
75
76
# File 'lib/user.rb', line 74

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

#get_company(id, options = nil) ⇒ Object

[View source]

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

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

#get_contact(id, options = nil) ⇒ Object

[View source]

57
58
59
# File 'lib/user.rb', line 57

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

[View source]

53
54
55
# File 'lib/user.rb', line 53

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

#get_content_instance(id, options = nil) ⇒ Object

[View source]

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

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

[View source]

159
160
161
# File 'lib/user.rb', line 159

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

#get_content_page(id, options = nil) ⇒ Object

[View source]

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

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

[View source]

180
181
182
# File 'lib/user.rb', line 180

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

#get_content_template(id, options = nil) ⇒ Object

[View source]

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

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

[View source]

201
202
203
# File 'lib/user.rb', line 201

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

#get_deal(id, options = nil) ⇒ Object

[View source]

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

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

[View source]

95
96
97
# File 'lib/user.rb', line 95

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

#get_location(id, options = nil) ⇒ Object

[View source]

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

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

[View source]

370
371
372
# File 'lib/user.rb', line 370

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

#get_price(id, options = nil) ⇒ Object

[View source]

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

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

#get_price_list(id, options = nil) ⇒ Object

[View source]

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

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

[View source]

285
286
287
# File 'lib/user.rb', line 285

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

[View source]

264
265
266
# File 'lib/user.rb', line 264

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

#get_prodict_brand(id, options = nil) ⇒ Object

[View source]

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

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

#get_prodict_template(id, options = nil) ⇒ Object

[View source]

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

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

#get_prodict_type(id, options = nil) ⇒ Object

[View source]

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

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

#get_product(id, options = nil) ⇒ Object

[View source]

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

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

[View source]

306
307
308
# File 'lib/user.rb', line 306

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

[View source]

348
349
350
# File 'lib/user.rb', line 348

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

[View source]

327
328
329
# File 'lib/user.rb', line 327

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

[View source]

222
223
224
# File 'lib/user.rb', line 222

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

#get_sku(id, options = nil) ⇒ Object

[View source]

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

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

[View source]

243
244
245
# File 'lib/user.rb', line 243

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

[View source]

117
118
119
# File 'lib/user.rb', line 117

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

#get_story(id, options = nil) ⇒ Object

[View source]

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

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

#get_story_template(id, options = nil) ⇒ Object

[View source]

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

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

[View source]

138
139
140
# File 'lib/user.rb', line 138

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

[View source]

391
392
393
# File 'lib/user.rb', line 391

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

#get_taxonomy(id, options = nil) ⇒ Object

[View source]

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

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

#login(email, password) ⇒ Object

[View source]

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

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

[View source]

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

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

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

[View source]

65
66
67
# File 'lib/user.rb', line 65

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

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

[View source]

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

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

[View source]

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

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

[View source]

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

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

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

[View source]

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

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

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

[View source]

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

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

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

[View source]

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

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

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

[View source]

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

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

[View source]

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

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

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

[View source]

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

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

[View source]

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

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

[View source]

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

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

[View source]

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

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

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

[View source]

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

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

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

[View source]

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

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

[View source]

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

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