Class: Profile

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

Defined Under Namespace

Classes: Documents, Json, Parsing, Rating, Revealing, Scoring, Stage

Constant Summary collapse

DEFAULT_DATE_START =
'1347209668'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clientw) ⇒ Profile

Returns a new instance of Profile.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/profile.rb', line 15

def initialize(clientw)
    @clientw = clientw

    @document = Documents.new(@clientw)
    @parsing = Parsing.new(@clientw)
    @scoring = Scoring.new(@clientw)
    @json = Json.new(@clientw)
    @stage = Stage.new(@clientw)
    @rating = Rating.new(@clientw)
    @revealing = Revealing.new(@clientw)

end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



6
7
8
# File 'lib/profile.rb', line 6

def document
  @document
end

#jsonObject (readonly)

Returns the value of attribute json.



9
10
11
# File 'lib/profile.rb', line 9

def json
  @json
end

#parsingObject (readonly)

Returns the value of attribute parsing.



7
8
9
# File 'lib/profile.rb', line 7

def parsing
  @parsing
end

#ratingObject (readonly)

Returns the value of attribute rating.



11
12
13
# File 'lib/profile.rb', line 11

def rating
  @rating
end

#revealingObject (readonly)

Returns the value of attribute revealing.



12
13
14
# File 'lib/profile.rb', line 12

def revealing
  @revealing
end

#scoringObject (readonly)

Returns the value of attribute scoring.



8
9
10
# File 'lib/profile.rb', line 8

def scoring
  @scoring
end

#stageObject (readonly)

Returns the value of attribute stage.



10
11
12
# File 'lib/profile.rb', line 10

def stage
  @stage
end

Instance Method Details

#add(options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/profile.rb', line 28

def add(options)
    if (!options.key?('filepath'))
        raise RiminderArgumentException.new('A filepath should be given')
    end
    file_path = options['filepath']
    payload = {
        'source_id' => options['source_id']
    }
    payload = ReqUtils.add_if_not_blank(payload, 'profile_reference', options['profile_reference'])
    payload = ReqUtils.add_if_not_blank(payload, 'timestamp_reception', options['timestamp_reception'])
    payload = ReqUtils.add_if_not_blank(payload, 'training_metadata', ReqUtils.(options['training_metadata']))
    resp = @clientw.postfile('profile', file_path, payload)
    return resp["data"]
end

#get(options) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/profile.rb', line 44

def get(options)
    query = {
        "source_id" => options['source_id']
    }
    query = ReqUtils.add_if_not_blank(query, 'profile_id', options['profile_id'])
    query = ReqUtils.add_if_not_blank(query, 'profile_reference', options['profile_reference'])
    resp = @clientw.get("profile", query)
    return resp["data"]
end

#list(options) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/profile.rb', line 54

def list(options)
    if (!options['source_ids'].nil? && !options['source_ids'].kind_of?(Array))
        raise RiminderArgumentException.new('options should contains a the source_ids field a an Array')
    end
    query = {
        'source_ids' => options['source_ids'].to_json,
        'date_start' => DEFAULT_DATE_START,
        'date_end' => Time.now.to_i,
        'page' => 1,
        'sort_by' => 'ranking'
    }
    query = ReqUtils.add_if_not_blank(query, 'seniority', options['seniority'])
    query = ReqUtils.add_if_not_blank(query, 'filter_id', options['filter_id'])
    query = ReqUtils.add_if_not_blank(query, 'filter_reference', options['filter_reference'])
    query = ReqUtils.add_if_not_blank(query, 'stage', options['stage'])
    query = ReqUtils.add_if_not_blank(query, 'rating', options['rating'])
    query = ReqUtils.add_if_not_blank(query, 'date_start', options['date_start'])
    query = ReqUtils.add_if_not_blank(query, 'date_end', options['date_end'])
    query = ReqUtils.add_if_not_blank(query, 'page', options['page'])
    query = ReqUtils.add_if_not_blank(query, 'limit', options['limit'])
    query = ReqUtils.add_if_not_blank(query, 'sort_by', options['sort_by'])
    query = ReqUtils.add_if_not_blank(query, 'order_by', options['order_by'])

    resp = @clientw.get('profiles', query)
    return resp["data"]
end