class AnetworkDynamicAd::Client

Attributes

api_url[RW]

setter and getter

request[RW]

setter and getter

toke[RW]

setter and getter

url[RW]

setter and getter

Public Class Methods

new(token) click to toggle source

Set token

@author Alireza Josheghani <a.josheghani@anetwork.ir> @since 24 Nov 2016 @param [string] token @return [void]

# File src/Client.rb, line 15
def initialize(token)
  @api_url = 'http://api.anetwork.ir/dynamicad/'
  @token = token
end

Public Instance Methods

delete(id) click to toggle source

Delete record

@author Alireza Josheghani <a.josheghani@anetwork.ir> @since 24 Nov 2016 @param [integer] id @return [Json]

# File src/Client.rb, line 96
def delete(id)
  params = {
      _METHOD: 'DELETE',
      id: id
  }
  puts Request.http(@url,'POST',params)
end
get() click to toggle source

Get results

@author Alireza Josheghani <a.josheghani@anetwork.ir> @since 24 Nov 2016 @return [json]

# File src/Client.rb, line 110
def get
  puts Request.http(@url,'GET')
end
id(id) click to toggle source

Get by id

@author Alireza Josheghani <a.josheghani@anetwork.ir> @since 24 Nov 2016 @param [integer] id @return [Object]

# File src/Client.rb, line 49
def id(id)
  @url = "#{@url}&id=#{id}"
  self
end
insert(params) click to toggle source

Insert records

@author Alireza Josheghani <a.josheghani@anetwork.ir> @since 24 Nov 2016 @param [Object] params @return [Json]

# File src/Client.rb, line 73
def insert(params)
  puts Request.http(@url,'POST',params)
end
limit(limit = 999,offset = 0) click to toggle source

Set limit and offset

@author Alireza Josheghani <a.josheghani@anetwork.ir> @since 24 Nov 2016 @param [integer] limit @param [integer] offset

# File src/Client.rb, line 61
def limit(limit = 999,offset = 0)
  @url = "#{@url}&limit=#{limit}&offset=#{offset}"
  self
end
product() click to toggle source

Get products

@author Alireza Josheghani <a.josheghani@anetwork.ir> @since 24 Nov 2016 @return [Object]

# File src/Client.rb, line 26
def product
  @url = "#{@api_url}?token=#{@token}"
  self
end
update(params) click to toggle source

Update records

@author Alireza Josheghani <a.josheghani@anetwork.ir> @since 24 Nov 2016 @param [Object] params @return [Json]

# File src/Client.rb, line 84
def update(params)
  params['_METHOD'] = 'PUT'
  puts Request.http(@url,'POST',params)
end