Class: MoverIO::Session
- Inherits:
-
Object
- Object
- MoverIO::Session
- Defined in:
- lib/mover_io.rb
Constant Summary collapse
- DEFAULT_HOST =
'api.mover.io'
- DEFAULT_PROTOCOL =
'http://'
Instance Method Summary collapse
-
#available_connectors ⇒ Object
CONNECTORS ################.
- #create_collection(name, connector_id, collection_id) ⇒ Object
- #create_connector(type) ⇒ Object
-
#create_transfer(source_connector_id, source_collection_id, destination_connector_id, destination_collection_id) ⇒ Object
TRANSFER ################.
-
#find_collection(connector_id, collection_id = nil) ⇒ Object
COLLECTIONS ################.
- #find_connector(connector_id) ⇒ Object
-
#initialize(options) ⇒ Session
constructor
A new instance of Session.
Constructor Details
#initialize(options) ⇒ Session
Returns a new instance of Session.
9 10 11 12 13 14 15 |
# File 'lib/mover_io.rb', line 9 def initialize() @app_id = [:app_id] @app_secret = [:app_secret] @host = .has_key?(:host) ? [:host] : DEFAULT_HOST @protocol = .has_key?(:protocol) ? [:protocol] : DEFAULT_PROTOCOL end |
Instance Method Details
#available_connectors ⇒ Object
CONNECTORS ################
19 20 21 22 23 24 25 26 |
# File 'lib/mover_io.rb', line 19 def available_connectors response = RestClient.get "#{base_url}/connectors/available" if response.code == 200 JSON.parse response.to_str else false end end |
#create_collection(name, connector_id, collection_id) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/mover_io.rb', line 57 def create_collection(name, connector_id, collection_id) payload = {:name => name, :parent_id => collection_id} response = RestClient.post "#{base_url}/connectors/#{connector_id}/collections", payload.to_json, {:authorization => "MoverAPI app_id=#{@app_id} app_secret=#{@app_secret}", :content_type => :json} if response.code == 201 JSON.parse response.to_str else false end end |
#create_connector(type) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/mover_io.rb', line 37 def create_connector(type) response = RestClient.post "#{base_url}/connectors", { 'type' => type }.to_json, {:authorization => "MoverAPI app_id=#{@app_id} app_secret=#{@app_secret}", :content_type => :json} if response.code == 201 JSON.parse response.to_str else false end end |
#create_transfer(source_connector_id, source_collection_id, destination_connector_id, destination_collection_id) ⇒ Object
TRANSFER ################
68 69 70 71 72 73 74 75 76 |
# File 'lib/mover_io.rb', line 68 def create_transfer(source_connector_id, source_collection_id, destination_connector_id, destination_collection_id ) payload = {:source => {:connector_id => source_connector_id, :collection_id => source_collection_id}, :destination => {:connector_id => destination_connector_id, :collection_id => destination_collection_id}} response = RestClient.post "#{base_url}/transfers", payload.to_json, {:authorization => "MoverAPI app_id=#{@app_id} app_secret=#{@app_secret}", :content_type => :json} if response.code == 201 JSON.parse response.to_str else false end end |
#find_collection(connector_id, collection_id = nil) ⇒ Object
COLLECTIONS ################
48 49 50 51 52 53 54 55 |
# File 'lib/mover_io.rb', line 48 def find_collection(connector_id, collection_id = nil) response = RestClient.get "#{base_url}/connectors/#{connector_id}/collections/#{collection_id}", {:authorization => "MoverAPI app_id=#{@app_id} app_secret=#{@app_secret}"} if response.code == 200 JSON.parse response.to_str else false end end |
#find_connector(connector_id) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/mover_io.rb', line 28 def find_connector(connector_id) response = RestClient.get "#{base_url}/connectors/#{connector_id}", {:authorization => "MoverAPI app_id=#{@app_id} app_secret=#{@app_secret}"} if response.code == 200 JSON.parse response.to_str else false end end |