Class: Bidi2pdf::Bidi::Commands::SetUsercontextCookie

Inherits:
SetTabCookie
  • Object
show all
Includes:
Base
Defined in:
lib/bidi2pdf/bidi/commands/set_usercontext_cookie.rb

Instance Attribute Summary collapse

Attributes inherited from SetTabCookie

#browsing_context_id, #domain, #http_only, #name, #path, #same_site, #secure, #ttl, #value

Instance Method Summary collapse

Methods included from Base

#==, #as_payload, #eql?, #hash, #inspect

Constructor Details

#initialize(name:, value:, domain:, user_context_id:, source_origin:, path: "/", secure: true, http_only: false, same_site: "strict", ttl: 30) ⇒ SetUsercontextCookie

Returns a new instance of SetUsercontextCookie.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bidi2pdf/bidi/commands/set_usercontext_cookie.rb', line 11

def initialize(name:,
               value:,
               domain:,
               user_context_id:,
               source_origin:,
               path: "/",
               secure: true,
               http_only: false,
               same_site: "strict",
               ttl: 30)
  super(name: name, value: value,
        domain: domain,
        path: path,
        secure: secure,
        http_only: http_only,
        same_site: same_site,
        ttl: ttl,
        browsing_context_id: nil)

  @user_context_id = user_context_id
  @source_origin = source_origin
end

Instance Attribute Details

#source_originObject (readonly)

Returns the value of attribute source_origin.



9
10
11
# File 'lib/bidi2pdf/bidi/commands/set_usercontext_cookie.rb', line 9

def source_origin
  @source_origin
end

#user_context_idObject (readonly)

Returns the value of attribute user_context_id.



9
10
11
# File 'lib/bidi2pdf/bidi/commands/set_usercontext_cookie.rb', line 9

def user_context_id
  @user_context_id
end

Instance Method Details

#expiryObject



34
35
36
# File 'lib/bidi2pdf/bidi/commands/set_usercontext_cookie.rb', line 34

def expiry
  Time.now.to_i + ttl
end

#method_nameObject



38
39
40
# File 'lib/bidi2pdf/bidi/commands/set_usercontext_cookie.rb', line 38

def method_name
  "storage.setCookie"
end

#paramsObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bidi2pdf/bidi/commands/set_usercontext_cookie.rb', line 42

def params
  {
    cookie: {
      name: name,
      value: {
        type: "string",
        value: value
      },
      domain: domain,
      path: path,
      secure: secure,
      httpOnly: http_only,
      sameSite: same_site,
      expiry: expiry
    },
    partition: {
      type: "storageKey",
      userContext: user_context_id,
      sourceOrigin: source_origin
    }
  }.compact
end