AuthorizeNet / sdk-ruby

Ruby SDK for the Authorize.Net API
Other
87 stars 111 forks source link

Use standard Ruby syntax for initializing objects. #143

Closed starrychloe closed 5 years ago

starrychloe commented 6 years ago

Instead of specifying every attribute on a separate line, like

    setting = SettingType.new
    setting.settingName = SettingNameEnum::HostedProfileReturnUrl
    setting.settingValue = "https://returnurl.com/return/"

Use standard Ruby syntax to specify the attributes of the object when creating it like

    setting1 = SettingType.new settingName: SettingNameEnum::HostedProfileReturnUrl, settingValue: "https://www.example.com/return"

If you try this, then you get an error

E00013 Setting Name '{:settingName=>"hostedProfileReturnUrl", :settingValue=>"https://www.example.com/return/"}' is invalid for this method.

It's like it's turning the hash into a string and using that as a settingName.

Also it's convention to use snake_case for variables like setting_name instead of settingName, but I don't care about that.

gnongsie commented 5 years ago

Hi,

This message has been communicated to the team and we will try to adhere to the conventions of the language as much as possible.

As per our analysis, the solution for the above is, we need to write the code in below fashion with Brackets.

setting=SettingType.new (settingName = SettingNameEnum::HostedProfileReturnUrl, settingValue = https://returnurl.com/return/)

chsriniv9 commented 5 years ago

Standard Ruby syntax is used for initializing objects, Ruby sample codes are modified accordingly, refer PR61