Class: Browserbeam::Sessions
- Inherits:
-
Object
- Object
- Browserbeam::Sessions
- Defined in:
- lib/browserbeam/client.rb
Instance Method Summary collapse
- #create(url: nil, steps: nil, timeout: nil, viewport: nil, user_agent: nil, locale: nil, timezone: nil, proxy: nil, block_resources: nil, auto_dismiss_blockers: nil, cookies: nil, idempotency_key: nil) ⇒ Object
- #destroy(session_id) ⇒ Object
- #get(session_id) ⇒ Object
-
#initialize(http) ⇒ Sessions
constructor
A new instance of Sessions.
- #list(status: nil, limit: nil, after: nil) ⇒ Object
Constructor Details
#initialize(http) ⇒ Sessions
Returns a new instance of Sessions.
15 16 17 |
# File 'lib/browserbeam/client.rb', line 15 def initialize(http) @http = http end |
Instance Method Details
#create(url: nil, steps: nil, timeout: nil, viewport: nil, user_agent: nil, locale: nil, timezone: nil, proxy: nil, block_resources: nil, auto_dismiss_blockers: nil, cookies: nil, idempotency_key: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/browserbeam/client.rb', line 19 def create(url: nil, steps: nil, timeout: nil, viewport: nil, user_agent: nil, locale: nil, timezone: nil, proxy: nil, block_resources: nil, auto_dismiss_blockers: nil, cookies: nil, idempotency_key: nil) body = {} body[:url] = url if url body[:steps] = steps if steps body[:timeout] = timeout if timeout body[:viewport] = if body[:user_agent] = user_agent if user_agent body[:locale] = locale if locale body[:timezone] = timezone if timezone body[:proxy] = proxy if proxy body[:block_resources] = block_resources if block_resources body[:auto_dismiss_blockers] = auto_dismiss_blockers unless auto_dismiss_blockers.nil? body[:cookies] = if extra_headers = {} extra_headers["Idempotency-Key"] = idempotency_key if idempotency_key data = @http.post("/v1/sessions", body, extra_headers) envelope = SessionEnvelope.from_hash(data) Session.new(envelope, @http) end |
#destroy(session_id) ⇒ Object
57 58 59 60 |
# File 'lib/browserbeam/client.rb', line 57 def destroy(session_id) @http.delete("/v1/sessions/#{session_id}") nil end |
#get(session_id) ⇒ Object
43 44 45 46 |
# File 'lib/browserbeam/client.rb', line 43 def get(session_id) data = @http.get("/v1/sessions/#{session_id}") SessionInfo.from_hash(data) end |
#list(status: nil, limit: nil, after: nil) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/browserbeam/client.rb', line 48 def list(status: nil, limit: nil, after: nil) params = {} params[:status] = status if status params[:limit] = limit if limit params[:after] = after if after data = @http.get("/v1/sessions", params) SessionList.from_hash(data) end |