Class: Sendowl::License

Inherits:
Object
  • Object
show all
Defined in:
lib/sendowl/resources/license.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product_id:, key:, id: nil, order_id: nil, order_refunded: nil) ⇒ License

Returns a new instance of License.



5
6
7
8
9
10
11
# File 'lib/sendowl/resources/license.rb', line 5

def initialize(product_id:, key:, id: nil, order_id: nil, order_refunded: nil)
  @id = id
  @order_id = order_id
  @product_id = product_id
  @key = key
  @order_refunded = order_refunded
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/sendowl/resources/license.rb', line 3

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/sendowl/resources/license.rb', line 3

def key
  @key
end

#order_idObject (readonly)

Returns the value of attribute order_id.



3
4
5
# File 'lib/sendowl/resources/license.rb', line 3

def order_id
  @order_id
end

#order_refundedObject (readonly)

Returns the value of attribute order_refunded.



3
4
5
# File 'lib/sendowl/resources/license.rb', line 3

def order_refunded
  @order_refunded
end

#product_idObject (readonly)

Returns the value of attribute product_id.



3
4
5
# File 'lib/sendowl/resources/license.rb', line 3

def product_id
  @product_id
end

Class Method Details

.parse(response) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sendowl/resources/license.rb', line 23

def parse(response)
  case response
  when Array
    response.map { |x| parse x }
  when Hash
    if response["licenses"]
      response["licenses"]["invalid_keys"]
    else
      new response["license"].transform_keys { |k| k.to_sym }
    end
  else
    response
  end
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
# File 'lib/sendowl/resources/license.rb', line 13

def valid?
  Sendowl::Request.new(
    check_valid_path,
    "GET",
    self.class,
    { query: { key: key } }
  ).call.first
end