Class: RecordMedium::Import

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

Overview

Import methods

Constant Summary collapse

HOST =
'https://recordmedium.com'
API =
'v1'

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Import

Returns a new instance of Import.

Raises:

  • (ArgumentError)


9
10
11
12
# File 'lib/record_medium/import.rb', line 9

def initialize(key)
  @key = key
  raise ArgumentError, 'No key' unless @key
end

Instance Method Details

#add(data) ⇒ Object



14
15
16
# File 'lib/record_medium/import.rb', line 14

def add(data)
  HTTParty.post("#{HOST}/api/#{API}/records/#{@key}/add", data_params(data))
end

#data_params(data) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/record_medium/import.rb', line 22

def data_params(data)
  {
    body: {
      data: data.to_json
    }
  }
end

#set(data) ⇒ Object



18
19
20
# File 'lib/record_medium/import.rb', line 18

def set(data)
  HTTParty.post("#{HOST}/api/#{API}/records/#{@key}/set", data_params(data))
end