Class: Seatsio::SubaccountsClient

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

Instance Method Summary collapse

Constructor Details

#initialize(secret_key, base_url) ⇒ SubaccountsClient

Returns a new instance of SubaccountsClient.



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

def initialize(secret_key, base_url)
  @http_client = ::Seatsio::HttpClient.new(secret_key, base_url)
end

Instance Method Details

#activate(id:) ⇒ Object



45
46
47
# File 'lib/seatsio/subaccounts.rb', line 45

def activate(id:)
  @http_client.post("/subaccounts/#{id}/actions/activate")
end

#activeObject



37
38
39
# File 'lib/seatsio/subaccounts.rb', line 37

def active
  cursor status: 'active'
end

#copy_chart_to_parent(id: nil, chart_key: nil) ⇒ Object



58
59
60
61
# File 'lib/seatsio/subaccounts.rb', line 58

def copy_chart_to_parent(id: nil, chart_key: nil)
  response = @http_client.post("/subaccounts/#{id}/charts/#{chart_key}/actions/copy-to/parent")
  Domain::Chart.new(response)
end

#copy_chart_to_subaccount(from_id: nil, to_id: nil, chart_key: nil) ⇒ Object



63
64
65
66
# File 'lib/seatsio/subaccounts.rb', line 63

def copy_chart_to_subaccount(from_id: nil, to_id: nil, chart_key: nil)
  response = @http_client.post("/subaccounts/#{from_id}/charts/#{chart_key}/actions/copy-to/#{to_id}")
  Domain::Chart.new(response)
end

#create(name: nil, email: nil) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/seatsio/subaccounts.rb', line 15

def create(name: nil, email: nil)
  body = {}
  body['name'] = name if name
  body['email'] = email if email

  response = @http_client.post("subaccounts", body)
  Domain::Subaccount.new(response)
end

#create_with_email(email: nil, name: nil) ⇒ Object



68
69
70
# File 'lib/seatsio/subaccounts.rb', line 68

def create_with_email(email: nil, name: nil)
  do_create name: name, email: email
end

#deactivate(id:) ⇒ Object



49
50
51
# File 'lib/seatsio/subaccounts.rb', line 49

def deactivate(id:)
  @http_client.post("/subaccounts/#{id}/actions/deactivate")
end

#inactiveObject



41
42
43
# File 'lib/seatsio/subaccounts.rb', line 41

def inactive
  cursor status: 'inactive'
end

#list(filter: nil) ⇒ Object



31
32
33
34
35
# File 'lib/seatsio/subaccounts.rb', line 31

def list(filter: nil)
  extended_cursor = cursor
  extended_cursor.set_query_param('filter', filter)
  extended_cursor
end

#regenerate_designer_key(id:) ⇒ Object



76
77
78
# File 'lib/seatsio/subaccounts.rb', line 76

def regenerate_designer_key(id:)
  @http_client.post("/subaccounts/#{id}/designer-key/actions/regenerate")
end

#regenerate_secret_key(id:) ⇒ Object



72
73
74
# File 'lib/seatsio/subaccounts.rb', line 72

def regenerate_secret_key(id:)
  @http_client.post("/subaccounts/#{id}/secret-key/actions/regenerate")
end

#retrieve(id:) ⇒ Object



53
54
55
56
# File 'lib/seatsio/subaccounts.rb', line 53

def retrieve(id:)
  response = @http_client.get("/subaccounts/#{id}")
  Domain::Subaccount.new(response)
end

#update(id:, name: nil, email: nil) ⇒ Object



24
25
26
27
28
29
# File 'lib/seatsio/subaccounts.rb', line 24

def update(id:, name: nil, email: nil)
  body = {}
  body['name'] = name if name
  body['email'] = email if email
  @http_client.post("subaccounts/#{id}", body)
end