SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
38 stars 10 forks source link

Deprecate the Sketchup::Model#get_product_family instance method #85

Open DanRathbun opened 6 years ago

DanRathbun commented 6 years ago

SketchUp Ruby API Issue

(1) Deprecate the Sketchup::Model#get_product_family instance method.

(2) Create a new app_trial_state() module method for the SketchUp application, in either the Sketchup or Sketchup::Licensing modules. The latter is preferred as it is a frozen module.

(3) Create clones of the needed trial state constants in the proper module namespace.

(4) If the new method is compatible with the old deprecated one, then the old deprecated one can be made to simply call the new one.

Persons writing code for pre-18 versions can use a rescue modifier thus ...

state = Sketchup::Licensing::app_trial_state rescue Sketchup::active_model.get_product_family

Historical Note: The Sketchup::Model#get_product_family method should never have been an instance method, nor been encapsulated by the Sketchup::Model class.

Reference Question Issue:

Eneroth3 commented 6 years ago

There is already a is_pro? method on the SketchUp class so I think an is_trial? method suits there too. SketchUp::Licensing is according to its description used for extension licenses.

DanRathbun commented 6 years ago

SketchUp::Licensing is according to its description used for extension licenses.

Yes, I read this, which is why I wrote Sketchup OR ..., and why I prefixed the method name with "app_".

Regardless, the Sketchup::Licensing module belongs to Trimble and they can change it's description and use to suit the needs of the API. Currently the module has only one method whose name specifically refers to "extension", so it would make sense if an application specific method's name referred to the application.

The biggest reason to put this method in the Sketchup::Licensing module is so that this method cannot be changed. A frozen module is where things like this belong. (The Sketchup module is not frozen.)

Somewhere I logged a request to create an is_pro? method in the frozen Sketchup::Licensing module and deprecate the old one.

so I think an is_trial? method suits there too.

This might cause the need for is_licensed? (and perhaps an is_expired?) method as well. Otherwise for the expired state you need a compound test ...

if !Sketchup::Licensing.app_is_trial? && !Sketchup::Licensing.app_is_licensed?
  # expired !
end

And... if a "shop" desktop edition is released, then a Sketchup::Licensing.app_is_shop? method as well.

thomthom commented 6 years ago

Logged as SU-40199